From 340a2b4ac0bcc737e24aa6c0e383f1188aaaaf61 Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Tue, 19 Jul 2016 17:06:11 +0000 Subject: lib: Implement node comparison function Implement comparator for nodes, some miscellaneous cleanup. Signed-off-by: Quentin Young --- lib/grammar_sandbox.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'lib/grammar_sandbox.c') 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 lol", "lol", result); - cmd_parse_format_new ("test 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); } -- cgit v1.2.3