diff options
| author | Quentin Young <qlyoung@cumulusnetworks.com> | 2016-07-22 19:04:16 +0000 |
|---|---|---|
| committer | Quentin Young <qlyoung@cumulusnetworks.com> | 2016-07-22 19:04:16 +0000 |
| commit | 880e24a1e4cc78cb23ebdd72f2e5cea861cf8be2 (patch) | |
| tree | fefe79765d2c5932a4083e428843657b9d673edd /lib/command_parse.y | |
| parent | 18be0e599d1ba666e59a3d027e973eb41798f46f (diff) | |
lib: Reorganize some matching stuff
Introduce new node type, END_GN, and remove
is_leaf flags. Reorganize command_match.c & remove
internal functions from command_match.h. Start
rewriting command.h in command_new.h with changes
for new backend.
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Diffstat (limited to 'lib/command_parse.y')
| -rw-r--r-- | lib/command_parse.y | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/lib/command_parse.y b/lib/command_parse.y index 9c1b3fff24..9f28391748 100644 --- a/lib/command_parse.y +++ b/lib/command_parse.y @@ -43,6 +43,8 @@ struct graph_node *optnode_start, // start node for option set struct graph_node *selnode_start, // start node for selector set *selnode_end; // end node for selector set + +const char *input; %} %token <node> WORD @@ -73,7 +75,24 @@ struct graph_node *selnode_start, // start node for selector set %% start: sentence_root - cmd_token_seq; + cmd_token_seq +{ + // this should never happen... + if (currnode->type == END_GN) + yyerror("Unexpected leaf\n"); + + // create function pointer node + struct graph_node *end = new_node(END_GN); + + // set cmd_element + // <set> + + // add node + add_node(currnode, end); + + // check that we did not get back an existing node + // <check> +} sentence_root: WORD { @@ -279,6 +298,7 @@ option_token: %% void yyerror(char const *message) { + // fail on bad parse printf("Grammar error: %s\n", message); exit(EXIT_FAILURE); } @@ -296,7 +316,8 @@ cmd_parse_format(const char *string, const char *desc, struct graph_node *start) // trace parser yydebug = 1; // make flex read from a string - set_buffer_string(string); + input = string; + set_buffer_string(input); // initialize the start node of this command dfa startnode = start; // parse command into DFA |
