summaryrefslogtreecommitdiff
path: root/lib/command_parse.y
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2016-12-16 15:52:47 -0500
committerGitHub <noreply@github.com>2016-12-16 15:52:47 -0500
commit6cc1ba027fdfbe7f7f9c9aa552f36f80950a4a64 (patch)
tree4ff9ccbe3cb7bec1bb2e963ce469050fb4c9ae73 /lib/command_parse.y
parentbcfb39acd7539d303b4aa3cc11d9ef7464358543 (diff)
parentfd19e7a2c02e0440be21358f175b0059e80f1d0b (diff)
Merge pull request #6 from opensourcerouting/dev/osr/vty_pending
parser: accept non-words as first tokens & numbers as word tokens
Diffstat (limited to 'lib/command_parse.y')
-rw-r--r--lib/command_parse.y28
1 files changed, 6 insertions, 22 deletions
diff --git a/lib/command_parse.y b/lib/command_parse.y
index 43062eb5da..c920e11380 100644
--- a/lib/command_parse.y
+++ b/lib/command_parse.y
@@ -73,7 +73,7 @@
struct cmd_element *el;
struct graph *graph;
- struct graph_node *currnode, *startnode;
+ struct graph_node *currnode;
/* pointers to copy of command docstring */
char *docstr_start, *docstr;
@@ -91,7 +91,6 @@
/* union types for parsed rules */
%type <node> start
-%type <node> sentence_root
%type <node> literal_token
%type <node> placeholder_token
%type <node> simple_token
@@ -151,9 +150,7 @@
/* called automatically before yyparse */
%initial-action {
/* clear state pointers */
- ctx->currnode = ctx->startnode = NULL;
-
- ctx->startnode = vector_slot (ctx->graph->nodes, 0);
+ ctx->currnode = vector_slot (ctx->graph->nodes, 0);
/* copy docstring and keep a pointer to the copy */
if (ctx->el->doc)
@@ -173,15 +170,15 @@
%%
start:
- sentence_root cmd_token_seq
+ cmd_token_seq
{
// tack on the command element
terminate_graph (ctx, ctx->currnode);
}
-| sentence_root cmd_token_seq placeholder_token '.' '.' '.'
+| cmd_token_seq placeholder_token '.' '.' '.'
{
- if ((ctx->currnode = add_edge_dedup (ctx->currnode, $3)) != $3)
- graph_delete_node (ctx->graph, $3);
+ if ((ctx->currnode = add_edge_dedup (ctx->currnode, $2)) != $2)
+ graph_delete_node (ctx->graph, $2);
((struct cmd_token *)ctx->currnode->data)->allowrepeat = 1;
@@ -194,19 +191,6 @@ start:
}
;
-sentence_root: WORD
-{
- struct graph_node *root =
- new_token_node (ctx, WORD_TKN, strdup ($1), doc_next(ctx));
-
- if ((ctx->currnode = add_edge_dedup (ctx->startnode, root)) != root)
- graph_delete_node (ctx->graph, root);
-
- free ($1);
- $$ = ctx->currnode;
-}
-;
-
cmd_token_seq:
/* empty */
| cmd_token_seq cmd_token