summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@baturin.org>2017-01-14 13:40:41 +0700
committerDaniil Baturin <daniil@baturin.org>2017-01-14 13:40:41 +0700
commitbab64ac54eb9865c48dcc75ee398953374f5be37 (patch)
tree219a51ee0c5751dd7afa2d6ca6611f55bcaa4152
parent621d7bb43a9bb2c0941f91c7c3a5aa082aa87e1b (diff)
downloadvyconf-bab64ac54eb9865c48dcc75ee398953374f5be37.tar.gz
vyconf-bab64ac54eb9865c48dcc75ee398953374f5be37.zip
Use Menhir's build-in boption() for #INACTIVE and #EPHEMERAL
instead of home-grown equivalents.
-rw-r--r--src/curly_parser.mly20
1 files changed, 4 insertions, 16 deletions
diff --git a/src/curly_parser.mly b/src/curly_parser.mly
index 560d84c..54443b5 100644
--- a/src/curly_parser.mly
+++ b/src/curly_parser.mly
@@ -37,23 +37,11 @@
%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
{ v }
@@ -68,14 +56,14 @@ values:
;
leaf_node:
- | comment = opt_comment; inactive = opt_inactive; ephemeral = opt_ephemeral; name = IDENTIFIER; values = values; SEMI
+ | comment = opt_comment; inactive = boption(INACTIVE); ephemeral = boption(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 *)
+ | comment = opt_comment; inactive = boption(INACTIVE); ephemeral = boption(EPHEMERAL); name = IDENTIFIER; SEMI (* valueless node *)
{ Vytree.make_full {default_data with comment=comment; inactive=inactive; ephemeral=ephemeral} name [] }
;
node:
- | comment = opt_comment; inactive = opt_inactive; ephemeral = opt_ephemeral; name = IDENTIFIER; LEFT_BRACE; children = list(node_content); RIGHT_BRACE
+ | comment = opt_comment; inactive = boption(INACTIVE); ephemeral = boption(EPHEMERAL); name = IDENTIFIER; LEFT_BRACE; children = list(node_content); RIGHT_BRACE
{
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
@@ -89,7 +77,7 @@ node:
;
tag_node:
- | comment = opt_comment; inactive = opt_inactive; ephemeral = opt_ephemeral; name = IDENTIFIER; tag = IDENTIFIER; LEFT_BRACE; children = list(node_content); RIGHT_BRACE
+ | comment = opt_comment; inactive = boption(INACTIVE); ephemeral = boption(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; inactive=inactive; ephemeral=ephemeral} tag [] in