]> git.proxmox.com Git - mirror_frr.git/blame - lib/grammar_sandbox.c
lib: Fix some DFA construction bugs
[mirror_frr.git] / lib / grammar_sandbox.c
CommitLineData
51e156b3 1#include "command.h"
478bdaeb 2#include "command_parse.h"
4b0abf24 3#include "cmdtree.h"
51e156b3
QY
4
5#define GRAMMAR_STR "CLI grammar sandbox\n"
6
478bdaeb
QY
7DEFUN (grammar_test,
8 grammar_test_cmd,
9 "grammar .COMMAND",
51e156b3 10 GRAMMAR_STR
478bdaeb 11 "command to pass to new parser\n")
51e156b3 12{
478bdaeb
QY
13 size_t linesize = 0;
14 for (int i = 0; i < argc; i++)
15 linesize += strlen(argv[i]) + 1;
51e156b3 16
478bdaeb
QY
17 char* cat = malloc(linesize);
18 cat[0] = '\0';
19 for (int i = 0; i < argc; i++) {
20 strcat(cat, argv[i]);
21 if (i != argc)
22 strcat(cat, " ");
23 }
51e156b3 24
4b0abf24
QY
25 struct graph_node *result = new_node(NUL_GN);
26 /* cmd_parse_format_new((const char*) cat, "lol", result);*/
27 cmd_parse_format_new ("test <command|options> lol", "lol", result);
28 cmd_parse_format_new ("test <command|options> lol", "lol", result);
29 walk_graph(result, 0);
30
478bdaeb 31 return CMD_SUCCESS;
51e156b3
QY
32}
33
34
35void grammar_sandbox_init(void);
36void grammar_sandbox_init() {
478bdaeb 37 install_element (ENABLE_NODE, &grammar_test_cmd);
51e156b3 38}