blob: 0053b56e5f28eed4a883177f41964f40844fff59 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
%{
open Config_tree
%}
%token <string> IDENTIFIER
%token <string> STRING
%token <string> COMMENT
%token LEFT_BRACE
%token RIGHT_BRACE
%token LEFT_BRACKET
%token RIGHT_BRACKET
%token SEMI
%token EOF
%start <Config_tree.t> config
%%
opt_comment:
| (* empty *) { None }
| c = COMMENT { Some c }
value:
| v = STRING
{ v }
| v = IDENTIFIER
{ v }
;
values:
| v = value { [v] }
| LEFT_BRACKET; vs = separated_nonempty_list(SEMI, value); RIGHT_BRACKET
{ vs }
;
leaf_node:
| comment = opt_comment; name = IDENTIFIER; values = values; SEMI
{ Vytree.make_full {default_data with values=values; comment=comment} name []}
;
node:
| comment = opt_comment; name = IDENTIFIER; LEFT_BRACE; children = list(node_content); RIGHT_BRACE
{ let node = Vytree.make_full {default_data with comment=comment} name [] in List.fold_left Vytree.adopt node children }
;
node_content: n = node { n } | n = leaf_node { n };
%public config:
ns = list(node); EOF
{
let root = make "root" in List.fold_left Vytree.adopt root ns
}
;
|