]> git.puffer.fish Git - matthieu/frr.git/commitdiff
lib: Add vararg support
authorQuentin Young <qlyoung@cumulusnetworks.com>
Tue, 2 Aug 2016 16:40:03 +0000 (16:40 +0000)
committerQuentin Young <qlyoung@cumulusnetworks.com>
Tue, 2 Aug 2016 16:40:03 +0000 (16:40 +0000)
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
lib/command_parse.y

index 146c8b61015652961e682c37645075afa41c4058..57a0ba3f82b93bd655f614205e668f98e3626448 100644 (file)
@@ -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
 {