diff options
author | Pavel Machek <pavel@ucw.cz> | 1999-09-29 14:24:58 +0000 |
---|---|---|
committer | Pavel Machek <pavel@ucw.cz> | 1999-09-29 14:24:58 +0000 |
commit | 7db7b7db603a2d852066c313da76c72673a204fa (patch) | |
tree | 616fc676f406ebd7c88eeed1f9dce68249fcc006 /filter/config.Y | |
parent | 4caa2231fc75ed351b9a9f20a97a81ce5d4421d0 (diff) |
Case arg { 1: printf "one"; } works. You can not use two commands
after one label, yet.
Diffstat (limited to 'filter/config.Y')
-rw-r--r-- | filter/config.Y | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/filter/config.Y b/filter/config.Y index 6aa1285f..7b6a7326 100644 --- a/filter/config.Y +++ b/filter/config.Y @@ -21,7 +21,7 @@ CF_DECLS CF_KEYWORDS(FUNCTION, PRINT, CONST, ACCEPT, REJECT, ERROR, QUITBIRD, INT, BOOL, IP, PREFIX, PAIR, SET, STRING, - IF, THEN, ELSE, + IF, THEN, ELSE, CASE, TRUE, FALSE, RTA, FROM, GW, NET, LEN, @@ -29,7 +29,7 @@ CF_KEYWORDS(FUNCTION, PRINT, CONST, FILTER ) -%type <x> term block cmds cmd function_body ifthen constant print_one print_list var_list +%type <x> term block cmds cmd function_body ifthen constant print_one print_list var_list switch_body %type <f> filter filter_body %type <i> type break_command %type <e> set_item set_items @@ -118,6 +118,8 @@ function_def: cmds: /* EMPTY */ { $$ = NULL; } | cmd cmds { if ($1) { + if ($1->next) + bug("Command has next already set\n"); $1->next = $2; $$ = $1; } else $$ = $2; @@ -160,7 +162,6 @@ constant: term: term '+' term { $$ = f_new_inst(); $$->code = '+'; $$->a1.p = $1; $$->a2.p = $3; } - | term '=' term { $$ = f_new_inst(); $$->code = '=='; $$->a1.p = $1; $$->a2.p = $3; } | term '!' '=' term { $$ = f_new_inst(); $$->code = '!='; $$->a1.p = $1; $$->a2.p = $4; } | term '<' term { $$ = f_new_inst(); $$->code = '<'; $$->a1.p = $1; $$->a2.p = $3; } @@ -231,6 +232,22 @@ var_list: /* EMPTY */ { $$ = NULL; } } ; +switch_body: /* EMPTY */ { $$ = NULL; } + | term ':' block switch_body { + $$ = f_new_inst(); + $$->code = 'of'; + $$->a1.p = $1; + $$->a2.p = $3; + $$->next = $4; + } + | ELSE ':' block { + $$ = f_new_inst(); + $$->code = 'el'; + $$->a1.p = NULL; + $$->a2.p = $3; + } + ; + cmd: ifthen { $$ = $1; @@ -272,6 +289,12 @@ cmd: inst = inst->next; } } + | CASE term '{' switch_body '}' { + $$ = f_new_inst(); + $$->code = 'sw'; + $$->a1.p = $2; + $$->a2.p = $4; + } ; CF_END |