From 7db7b7db603a2d852066c313da76c72673a204fa Mon Sep 17 00:00:00 2001 From: Pavel Machek Date: Wed, 29 Sep 1999 14:24:58 +0000 Subject: Case arg { 1: printf "one"; } works. You can not use two commands after one label, yet. --- filter/config.Y | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) (limited to 'filter/config.Y') diff --git a/filter/config.Y b/filter/config.Y index 6aa1285..7b6a732 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 term block cmds cmd function_body ifthen constant print_one print_list var_list +%type term block cmds cmd function_body ifthen constant print_one print_list var_list switch_body %type filter filter_body %type type break_command %type 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 -- cgit v1.2.3