diff options
-rw-r--r-- | etc/bash_completion.d/20vyatta-cfg | 17 | ||||
-rw-r--r-- | src/cli_def.l | 18 | ||||
-rw-r--r-- | src/cli_parse.y | 5 |
3 files changed, 26 insertions, 14 deletions
diff --git a/etc/bash_completion.d/20vyatta-cfg b/etc/bash_completion.d/20vyatta-cfg index bc9088f..c8e4908 100644 --- a/etc/bash_completion.d/20vyatta-cfg +++ b/etc/bash_completion.d/20vyatta-cfg @@ -354,14 +354,13 @@ vyatta_parse_tmpl_comp_fields () # $1: tmpl # $2: field name sed -n ' - /^#'"$2"':/,$ { - s/^#'"$2"':// + /^'"$2"':/,$ { + s/^'"$2"':// h :b $ { x; p; q } n - /^#[-_a-z]\+:/ { x; p; q } - s/^#// + /^[-_a-z]\+:/ { x; p; q } H bb } @@ -387,12 +386,8 @@ vyatta_parse_tmpl () return fi eval `sed -n ' - /^help:[ ]\+/,/^[a-z]\+:/ { - s/^help:[ ]\+/vyatta_cfg_help=/p - /^ /p - } - /^syntax:[ ]\+\$(@)[ ]\+in[ ]\+/ { - s/^syntax:[ ]\+\$(@)[ ]\+in[ ]\+/vyatta_cfg_allowed=( / + /^syntax:expression:[ ]\+\$(@)[ ]\+in[ ]\+/ { + s/^syntax:expression:[ ]\+\$(@)[ ]\+in[ ]\+/vyatta_cfg_allowed=( / s/^\([^;]\+\);.*$/\1 )/ s/[ ]*,[ ]*/ /gp } @@ -401,6 +396,8 @@ vyatta_parse_tmpl () s/^type:[ ]\+\([^ ;]\+\)\(;.*\)\?/vyatta_cfg_type=\1/p ' $1` + vyatta_cfg_help=$(vyatta_parse_tmpl_comp_fields $1 "help") + local acmd=$(vyatta_parse_tmpl_comp_fields $1 "allowed") vyatta_cfg_comp_help=$(vyatta_parse_tmpl_comp_fields $1 "comp_help") diff --git a/src/cli_def.l b/src/cli_def.l index d959fb0..df768c1 100644 --- a/src/cli_def.l +++ b/src/cli_def.l @@ -21,13 +21,19 @@ static char *reg_fields[] = { "default", "tag", "type", "multi", NULL }; static int reg_fields_t[] = { DEFAULT, TAG, TYPE, MULTI, 0 }; static char *act_fields[] = { "help", "syntax", "commit", "delete", "update", "activate", "create", - "begin", "end", NULL }; + "begin", "end", + "comp_help", "allowed", + NULL }; static int act_fields_t[] = { HELP, SYNTAX, COMMIT, ACTION, ACTION, ACTION, ACTION, - ACTION, ACTION, 0 }; + ACTION, ACTION, + DUMMY, DUMMY, + 0 }; static int act_types[] = { -1, -1, -1, delete_act, update_act, activate_act, create_act, - begin_act, end_act, -1 }; + begin_act, end_act, + -1, -1, + -1 }; static char *type_names[] = { "txt", "u32", "ipv4", "ipv4net", "ipv6", "ipv6net", "bool", "macaddr", @@ -257,7 +263,7 @@ RE_OP_OTHER (pattern|exec|,|\|\||&&|=|!|\(|\)|;) /* template fields */ RE_REG_FIELD (default|tag|type|multi) -RE_ACT_FIELD (help|syntax|commit|delete|update|activate|create|begin|end) +RE_ACT_FIELD (help|syntax|commit|delete|update|activate|create|begin|end|comp_help|allowed) %% @@ -405,6 +411,10 @@ RE_ACT_FIELD (help|syntax|commit|delete|update|activate|create|begin|end) {RE_VAL_BOOL} { return return_value(BOOL_TYPE); } {RE_MACADDR} { return return_value(MACADDR_TYPE); } +. { + return SYNTAX_ERROR; + } + %% static void diff --git a/src/cli_parse.y b/src/cli_parse.y index 372f3a9..150fe71 100644 --- a/src/cli_parse.y +++ b/src/cli_parse.y @@ -34,6 +34,7 @@ static void cli_deferror(const char *); %token SYNTAX %token COMMIT %token CHECK +%token DUMMY %left SEMI %token <val>VALUE %token <type>TYPE_DEF @@ -100,8 +101,12 @@ cause: help_cause | default_cause | syntax_cause | ACTION action { append(parse_defp->actions + $1, $2, 0);} + | dummy_stmt ; +dummy_stmt: DUMMY STRING { /* ignored */ } + ; + help_cause: HELP STRING { parse_defp->def_node_help = $2; /* no semantics for now */ } |