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,
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
cmds: /* EMPTY */ { $$ = NULL; }
| cmd cmds {
if ($1) {
+ if ($1->next)
+ bug("Command has next already set\n");
$1->next = $2;
$$ = $1;
} else $$ = $2;
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; }
}
;
+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;
inst = inst->next;
}
}
+ | CASE term '{' switch_body '}' {
+ $$ = f_new_inst();
+ $$->code = 'sw';
+ $$->a1.p = $2;
+ $$->a2.p = $4;
+ }
;
CF_END