blob: 0cc6896d8e0225529f626fb9d11525a8e3f95b4d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
#include "command.h"
#include "command_parse.h"
#include "cmdtree.h"
#define GRAMMAR_STR "CLI grammar sandbox\n"
DEFUN (grammar_test,
grammar_test_cmd,
"grammar .COMMAND",
GRAMMAR_STR
"command to pass to new parser\n")
{
size_t linesize = 0;
for (int i = 0; i < argc; i++)
linesize += strlen(argv[i]) + 1;
char* cat = malloc(linesize);
cat[0] = '\0';
for (int i = 0; i < argc; i++) {
strcat(cat, argv[i]);
if (i != argc)
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);
return CMD_SUCCESS;
}
void grammar_sandbox_init(void);
void grammar_sandbox_init() {
install_element (ENABLE_NODE, &grammar_test_cmd);
}
|