diff options
Diffstat (limited to 'lib/grammar_sandbox.h')
| -rw-r--r-- | lib/grammar_sandbox.h | 48 |
1 files changed, 29 insertions, 19 deletions
diff --git a/lib/grammar_sandbox.h b/lib/grammar_sandbox.h index 98d987668f..8cdcc2359c 100644 --- a/lib/grammar_sandbox.h +++ b/lib/grammar_sandbox.h @@ -1,7 +1,14 @@ +#ifndef _GRAMMAR_SANDBOX_H +#define _GRAMMAR_SANDBOX_H + +/** + * Houses functionality for testing shim as well as code that should go into + * command.h and command.c during integration. + */ #include "memory.h" void -grammar_sandbox_init(void); +grammar_sandbox_init (void); /** * Types for tokens. @@ -11,9 +18,8 @@ grammar_sandbox_init(void); */ enum cmd_token_type_t { - _TOKEN_BUG = 0, - LITERAL_TKN, // words - OPTION_TKN, // integer ranges + WORD_TKN, // words + NUMBER_TKN, // integral numbers VARIABLE_TKN, // almost anything RANGE_TKN, // integer range IPV4_TKN, // IPV4 addresses @@ -22,13 +28,13 @@ enum cmd_token_type_t IPV6_PREFIX_TKN, // IPV6 network prefixes /* plumbing types */ - SELECTOR, // marks beginning of selector - OPTION, // marks beginning of option - NUL, // dummy token - START, // first token in line - END; // last token in line -}; - + SELECTOR_TKN, // marks beginning of selector + OPTION_TKN, // marks beginning of option + NUL_TKN, // dummy token + START_TKN, // first token in line + END_TKN, // last token in line +}; + /** * Token struct. */ @@ -41,13 +47,17 @@ struct cmd_token_t long long value; // for numeric types long long min, max; // for ranges + + char *arg; // user input that matches this token }; -inline struct cmd_token_t * -cmd_new_token (cmd_token_type_t type, char *text, char *desc) -{ - struct cmd_token_t *token = XMALLOC (MTYPE_CMD_TOKENS, sizeof (struct cmd_token_t)); - token->type = type; - token->text = text; - token->desc = desc; -} +struct cmd_token_t * +new_cmd_token (enum cmd_token_type_t, char *, char *); + +void +del_cmd_token (struct cmd_token_t *); + +struct cmd_token_t * +copy_cmd_token (struct cmd_token_t *); + +#endif /* _GRAMMAR_SANDBOX_H */ |
