From: Quentin Young Date: Tue, 2 Aug 2016 16:40:03 +0000 (+0000) Subject: lib: Add vararg support X-Git-Tag: frr-3.0-branchpoint~129^2~269 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=88255c7cfbd2da60c52eeea57b62a63c21264ab0;p=matthieu%2Ffrr.git lib: Add vararg support Signed-off-by: Quentin Young --- diff --git a/lib/command_parse.y b/lib/command_parse.y index 146c8b6101..57a0ba3f82 100644 --- a/lib/command_parse.y +++ b/lib/command_parse.y @@ -78,8 +78,8 @@ struct cmd_element *command; // command we're parsing /* grammar proper */ %% -start: sentence_root - cmd_token_seq +start: + sentence_root cmd_token_seq { // create leaf node struct graph_node *end = new_node(END_GN); @@ -93,6 +93,29 @@ start: sentence_root } fprintf(stderr, "Parsed full command successfully.\n"); } +| sentence_root cmd_token_seq '.' placeholder_token +{ + currnode = add_node(currnode, $4); + if (currnode != $4) + free_node ($4); + + // since varargs may match any number of the last token, + // simply add this node as a child of itself and proceed + // wth normal command termination procedure + add_node(currnode, currnode); + + // create leaf node + struct graph_node *end = new_node(END_GN); + end->element = command; + + // add node + if (add_node(currnode, end) != end) + { + yyerror("Duplicate command."); + YYABORT; + } + fprintf(stderr, "Parsed full command successfully.\n"); +} sentence_root: WORD {