From bab64ac54eb9865c48dcc75ee398953374f5be37 Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Sat, 14 Jan 2017 13:40:41 +0700 Subject: Use Menhir's build-in boption() for #INACTIVE and #EPHEMERAL instead of home-grown equivalents. --- src/curly_parser.mly | 20 ++++---------------- 1 file 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 %% -(* 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 -- cgit v1.2.3