]> git.puffer.fish Git - matthieu/frr.git/commitdiff
lib: parser: track matching FORK_TKN & JOIN_TKN
authorDavid Lamparter <equinox@opensourcerouting.org>
Fri, 16 Dec 2016 21:34:35 +0000 (22:34 +0100)
committerDavid Lamparter <equinox@opensourcerouting.org>
Mon, 23 Jan 2017 20:52:44 +0000 (21:52 +0100)
This associates pairs of FORK and JOIN tokens, so the merge function can
identify where a subgraph begins and ends.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
lib/command.h
lib/command_parse.y

index dd940f0d573f87cc07b418c9b135511885af2f03..b71142fdce13b7a22aab91db7710f0d89e0b02e5 100644 (file)
@@ -203,6 +203,8 @@ struct cmd_token
   char *desc;                   // token description
   long long min, max;           // for ranges
   char *arg;                    // user input that matches this token
+
+  struct graph_node *forkjoin;  // paired FORK/JOIN for JOIN/FORK
 };
 
 /* Structure of command element. */
index 478ba0537c609fe19b7160a038e4c020d89db24f..af6497d1287a4edc853ef0bc8f47e3eeae1f169c 100644 (file)
@@ -276,6 +276,8 @@ selector: '<' selector_seq_seq '>'
   $$ = malloc (sizeof (struct subgraph));
   $$->start = new_token_node (ctx, FORK_TKN, NULL, NULL);
   $$->end   = new_token_node (ctx, JOIN_TKN, NULL, NULL);
+  ((struct cmd_token *)$$->start->data)->forkjoin = $$->end;
+  ((struct cmd_token *)$$->end->data)->forkjoin = $$->start;
   for (unsigned int i = 0; i < vector_active ($2->start->to); i++)
   {
     struct graph_node *sn = vector_slot ($2->start->to, i),
@@ -331,6 +333,8 @@ selector: '{' selector_seq_seq '}'
   $$ = malloc (sizeof (struct subgraph));
   $$->start = new_token_node (ctx, FORK_TKN, NULL, NULL);
   $$->end   = new_token_node (ctx, JOIN_TKN, NULL, NULL);
+  ((struct cmd_token *)$$->start->data)->forkjoin = $$->end;
+  ((struct cmd_token *)$$->end->data)->forkjoin = $$->start;
   graph_add_edge ($$->start, $$->end);
   for (unsigned int i = 0; i < vector_active ($2->start->to); i++)
   {
@@ -379,6 +383,8 @@ option: '[' option_token_seq ']'
   $$ = malloc (sizeof (struct subgraph));
   $$->start = new_token_node (ctx, FORK_TKN, NULL, NULL);
   $$->end   = new_token_node (ctx, JOIN_TKN, NULL, NULL);
+  ((struct cmd_token *)$$->start->data)->forkjoin = $$->end;
+  ((struct cmd_token *)$$->end->data)->forkjoin = $$->start;
   // add a path through the sequence to the end
   graph_add_edge ($$->start, $2->start);
   graph_add_edge ($2->end, $$->end);