diff options
author | Quentin Young <qlyoung@cumulusnetworks.com> | 2016-07-19 19:06:11 +0200 |
---|---|---|
committer | Quentin Young <qlyoung@cumulusnetworks.com> | 2016-07-19 19:06:11 +0200 |
commit | 340a2b4ac0bcc737e24aa6c0e383f1188aaaaf61 (patch) | |
tree | f0bf3ce9c04baa763464a8922ec8a227f7595edd /lib/grammar_sandbox.c | |
parent | lib: Fix some DFA construction bugs (diff) | |
download | frr-340a2b4ac0bcc737e24aa6c0e383f1188aaaaf61.tar.xz frr-340a2b4ac0bcc737e24aa6c0e383f1188aaaaf61.zip |
lib: Implement node comparison function
Implement comparator for nodes, some miscellaneous cleanup.
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Diffstat (limited to 'lib/grammar_sandbox.c')
-rw-r--r-- | lib/grammar_sandbox.c | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/lib/grammar_sandbox.c b/lib/grammar_sandbox.c index 0cc6896d8..807ada9d9 100644 --- a/lib/grammar_sandbox.c +++ b/lib/grammar_sandbox.c @@ -4,9 +4,11 @@ #define GRAMMAR_STR "CLI grammar sandbox\n" +struct graph_node * nodegraph; + DEFUN (grammar_test, grammar_test_cmd, - "grammar .COMMAND", + "grammar parse .COMMAND", GRAMMAR_STR "command to pass to new parser\n") { @@ -22,17 +24,28 @@ DEFUN (grammar_test, strcat(cat, " "); } - struct graph_node *result = new_node(NUL_GN); - /* cmd_parse_format_new((const char*) cat, "lol", result);*/ - cmd_parse_format_new ("test <command|options> lol", "lol", result); - cmd_parse_format_new ("test <command|options> lol", "lol", result); - walk_graph(result, 0); - + //struct graph_node *result = new_node(NUL_GN); + cmd_parse_format_new((const char*) cat, "lol", nodegraph); + walk_graph(nodegraph, 0); + return CMD_SUCCESS; } +DEFUN (grammar_test_show, + grammar_test_show_cmd, + "grammar tree", + GRAMMAR_STR + "print current accumulated DFA\n") +{ + walk_graph(nodegraph, 0); + return CMD_SUCCESS; +} + void grammar_sandbox_init(void); void grammar_sandbox_init() { + fprintf(stderr, "reinitializing graph\n"); + nodegraph = new_node(NUL_GN); install_element (ENABLE_NODE, &grammar_test_cmd); + install_element (ENABLE_NODE, &grammar_test_show_cmd); } |