Enums do not work, this is testcase.

This commit is contained in:
Pavel Machek 1999-11-10 13:59:13 +00:00
parent cb8034f42c
commit 1183b6b229
2 changed files with 9 additions and 5 deletions

View file

@ -46,6 +46,7 @@ ip p;
p = 127.1.2.3; p = 127.1.2.3;
print "Testing mask : 127.0.0.0 = " p.mask(8); print "Testing mask : 127.0.0.0 = " p.mask(8);
print "Testing pairs: (1,2) = " (1,2); print "Testing pairs: (1,2) = " (1,2);
print "Set of enums: " RTSDUMMY;
print "What will this do? " [ 1, 2, 1, 1, 1, 3, 4, 1, 1, 1, 5 ]; print "What will this do? " [ 1, 2, 1, 1, 1, 3, 4, 1, 1, 1, 5 ];

View file

@ -43,7 +43,7 @@ CF_KEYWORDS(FUNCTION, PRINT, PRINTN, CONST,
%nonassoc THEN %nonassoc THEN
*/ */
%type <x> term block cmds cmd function_body constant print_one print_list var_list var_listn any_dynamic %type <x> term block cmds cmd function_body constant print_one print_list var_list var_listn any_dynamic enums
%type <f> filter filter_body %type <f> filter filter_body
%type <i> type break_command pair enum_rts %type <i> type break_command pair enum_rts
%type <e> set_item set_items switch_body %type <e> set_item set_items switch_body
@ -248,6 +248,10 @@ enum_rts:
| RTSPIPE { $$ = 13; } | RTSPIPE { $$ = 13; }
; ;
enums:
enum_rts { $$ = f_new_inst(); $$->code = 'c'; $$->a1.i = T_ENUM_RTS; $$->a2.i = $1; }
;
constant: constant:
CONST '(' expr ')' { $$ = f_new_inst(); $$->code = 'c'; $$->a1.i = T_INT; $$->a2.i = $3; } CONST '(' expr ')' { $$ = f_new_inst(); $$->code = 'c'; $$->a1.i = T_INT; $$->a2.i = $3; }
| NUM { $$ = f_new_inst(); $$->code = 'c'; $$->a1.i = T_INT; $$->a2.i = $1; } | NUM { $$ = f_new_inst(); $$->code = 'c'; $$->a1.i = T_INT; $$->a2.i = $1; }
@ -258,8 +262,7 @@ constant:
| ipa { NEW_F_VAL; $$ = f_new_inst(); $$->code = 'C'; $$->a1.p = val; *val = $1; } | ipa { NEW_F_VAL; $$ = f_new_inst(); $$->code = 'C'; $$->a1.p = val; *val = $1; }
| prefix_s {NEW_F_VAL; $$ = f_new_inst(); $$->code = 'C'; $$->a1.p = val; *val = $1; } | prefix_s {NEW_F_VAL; $$ = f_new_inst(); $$->code = 'C'; $$->a1.p = val; *val = $1; }
| '[' set_items ']' { printf( "We've got a set here..." ); $$ = f_new_inst(); $$->code = 'c'; $$->a1.i = T_SET; $$->a2.p = build_tree($2); printf( "ook\n" ); } | '[' set_items ']' { printf( "We've got a set here..." ); $$ = f_new_inst(); $$->code = 'c'; $$->a1.i = T_SET; $$->a2.p = build_tree($2); printf( "ook\n" ); }
| enums { $$ = $1; }
| enum_rts { $$ = f_new_inst(); $$->code = 'c'; $$->a1.i = T_ENUM_RTS; $$->a2.i = $1; }
; ;
any_dynamic: any_dynamic:
@ -280,6 +283,7 @@ 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; }
| DEFINED '(' term ')' { $$ = f_new_inst(); $$->code = 'de'; $$->a1.p = $3; } | DEFINED '(' term ')' { $$ = f_new_inst(); $$->code = 'de'; $$->a1.p = $3; }
| constant { $$ = $1; }
| SYM { | SYM {
$$ = f_new_inst(); $$ = f_new_inst();
switch ($1->class) { switch ($1->class) {
@ -291,10 +295,9 @@ term:
$$->a1.p = $1->aux2; $$->a1.p = $1->aux2;
break; break;
default: default:
cf_error("Can not use this class of symbol as variable." ); cf_error("Can not use this class of symbol (%s,%x) as variable.", $1->name, $1->class );
} }
} }
| constant { $$ = $1; }
| RTA '.' FROM { $$ = f_new_inst(); $$->code = 'a'; $$->a1.i = T_IP; $$->a2.i = OFFSETOF(struct rta, from); } | RTA '.' FROM { $$ = f_new_inst(); $$->code = 'a'; $$->a1.i = T_IP; $$->a2.i = OFFSETOF(struct rta, from); }
| RTA '.' GW { $$ = f_new_inst(); $$->code = 'a'; $$->a1.i = T_IP; $$->a2.i = OFFSETOF(struct rta, gw); } | RTA '.' GW { $$ = f_new_inst(); $$->code = 'a'; $$->a1.i = T_IP; $$->a2.i = OFFSETOF(struct rta, gw); }