diff options
author | Quentin Young <qlyoung@cumulusnetworks.com> | 2016-07-17 23:49:16 +0200 |
---|---|---|
committer | Quentin Young <qlyoung@cumulusnetworks.com> | 2016-07-17 23:49:16 +0200 |
commit | 478bdaeb3b9699d2ceaa9607ef37166e7ca69faf (patch) | |
tree | 7f1cc818b840a6d4ac9a7b1e5ea88906d5de8d23 /lib/grammar_sandbox.c | |
parent | lib: Add generated parser files to .gitignore (diff) | |
download | frr-478bdaeb3b9699d2ceaa9607ef37166e7ca69faf.tar.xz frr-478bdaeb3b9699d2ceaa9607ef37166e7ca69faf.zip |
lib: Finish implementing grammar, DFA construction
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Diffstat (limited to 'lib/grammar_sandbox.c')
-rw-r--r-- | lib/grammar_sandbox.c | 56 |
1 files changed, 18 insertions, 38 deletions
diff --git a/lib/grammar_sandbox.c b/lib/grammar_sandbox.c index c19be7f93..fd0eec02d 100644 --- a/lib/grammar_sandbox.c +++ b/lib/grammar_sandbox.c @@ -1,53 +1,33 @@ #include "command.h" +#include "command_parse.h" #define GRAMMAR_STR "CLI grammar sandbox\n" -DEFUN (grammar_midkey_test, - grammar_midkey_test_cmd, - "grammar {one|two} test", +DEFUN (grammar_test, + grammar_test_cmd, + "grammar .COMMAND", GRAMMAR_STR - "First option\n" - "Second option\n" - "Test parameter to end string\n") + "command to pass to new parser\n") { - return CMD_SUCCESS; -} + size_t linesize = 0; + for (int i = 0; i < argc; i++) + linesize += strlen(argv[i]) + 1; -DEFUN (grammar_onemidkey_test, - grammar_onemidkey_test_cmd, - "grammar {onekey} test", - GRAMMAR_STR - "First option\n" - "Test parameter to end string\n") -{ - return CMD_SUCCESS; -} + char* cat = malloc(linesize); + cat[0] = '\0'; + for (int i = 0; i < argc; i++) { + strcat(cat, argv[i]); + if (i != argc) + strcat(cat, " "); + } -DEFUN (grammar_smashmouth_test, - grammar_smashmouth_test_cmd, - "grammar {smash MOUTH} test", - GRAMMAR_STR - "It ain't easy bein' cheesy\n" - "Test parameter to end string\n") -{ - return CMD_SUCCESS; -} + cmd_parse_format_new((const char*) cat, "lol"); -DEFUN (grammar_midopt_test, - grammar_midopt_test_cmd, - "grammar [option] test", - GRAMMAR_STR - "optional argument\n" - "Test parameter to end string\n") -{ - return CMD_SUCCESS; + return CMD_SUCCESS; } void grammar_sandbox_init(void); void grammar_sandbox_init() { - install_element (ENABLE_NODE, &grammar_midkey_test_cmd); - install_element (ENABLE_NODE, &grammar_onemidkey_test_cmd); - install_element (ENABLE_NODE, &grammar_midopt_test_cmd); - install_element (ENABLE_NODE, &grammar_smashmouth_test_cmd); + install_element (ENABLE_NODE, &grammar_test_cmd); } |