diff options
Diffstat (limited to 'src/curly_parser.mly')
| -rw-r--r-- | src/curly_parser.mly | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/src/curly_parser.mly b/src/curly_parser.mly index 7daa082..560d84c 100644 --- a/src/curly_parser.mly +++ b/src/curly_parser.mly @@ -25,6 +25,8 @@ %token <string> IDENTIFIER %token <string> STRING %token <string> COMMENT +%token INACTIVE +%token EPHEMERAL %token LEFT_BRACE %token RIGHT_BRACE %token LEFT_BRACKET @@ -35,9 +37,22 @@ %start <Config_tree.t> config %% +(* Shift-reduce conflicts are reduced to shift by default, + so it should be fine *) opt_comment: | (* empty *) { None } | c = COMMENT { Some (String.trim c) } +; + +opt_inactive: + | (* empty *) { false } + | INACTIVE { true } +; + +opt_ephemeral: + | (* empty *) { false } + | EPHEMERAL { true } +; value: | v = STRING @@ -53,16 +68,16 @@ values: ; leaf_node: - | comment = opt_comment; name = IDENTIFIER; values = values; SEMI - { Vytree.make_full {default_data with values=(List.rev values); comment=comment} name []} - | comment = opt_comment; name = IDENTIFIER; SEMI (* valueless node *) - { Vytree.make_full {default_data with comment=comment} name [] } + | comment = opt_comment; inactive = opt_inactive; ephemeral = opt_ephemeral; name = IDENTIFIER; values = values; SEMI + { Vytree.make_full {values=(List.rev values); comment=comment; inactive=inactive; ephemeral=ephemeral} name []} + | comment = opt_comment; inactive = opt_inactive; ephemeral = opt_ephemeral; name = IDENTIFIER; SEMI (* valueless node *) + { Vytree.make_full {default_data with comment=comment; inactive=inactive; ephemeral=ephemeral} name [] } ; node: - | comment = opt_comment; name = IDENTIFIER; LEFT_BRACE; children = list(node_content); RIGHT_BRACE + | comment = opt_comment; inactive = opt_inactive; ephemeral = opt_ephemeral; name = IDENTIFIER; LEFT_BRACE; children = list(node_content); RIGHT_BRACE { - let node = Vytree.make_full {default_data with comment=comment} name [] in + let node = Vytree.make_full {default_data with comment=comment; inactive=inactive; ephemeral=ephemeral} name [] in let node = List.fold_left Vytree.adopt node (List.rev children) |> Vytree.merge_children merge_data in try List.iter find_duplicate_children (Vytree.children_of_node node); @@ -74,10 +89,10 @@ node: ; tag_node: - | comment = opt_comment; name = IDENTIFIER; tag = IDENTIFIER; LEFT_BRACE; children = list(node_content); RIGHT_BRACE + | comment = opt_comment; inactive = opt_inactive; ephemeral = opt_ephemeral; name = IDENTIFIER; tag = IDENTIFIER; LEFT_BRACE; children = list(node_content); RIGHT_BRACE { let outer_node = Vytree.make_full default_data name [] in - let inner_node = Vytree.make_full {default_data with comment=comment} tag [] in + let inner_node = Vytree.make_full {default_data with comment=comment; inactive=inactive; ephemeral=ephemeral} tag [] in let inner_node = List.fold_left Vytree.adopt inner_node (List.rev children) |> Vytree.merge_children merge_data in let node = Vytree.adopt outer_node inner_node in try |
