%nonassoc ELSE
%type <xp> cmds_int cmd_prep
-%type <x> term term_bs cmd cmd_var cmds cmds_scoped constant constructor print_list var var_init var_list function_call symbol_value bgp_path_expr bgp_path bgp_path_tail
+%type <x> term term_bs cmd cmd_var cmds cmds_scoped constant constructor print_list var var_list function_call symbol_value bgp_path_expr bgp_path bgp_path_tail
%type <fda> dynamic_attr
%type <fsa> static_attr
%type <f> filter where_filter
}
;
-var_init:
- /* empty */ { $$ = f_new_inst(FI_CONSTANT, (struct f_val) { }); }
- | '=' term { $$ = $2; }
- ;
-
var:
- type symbol var_init ';' {
+ type symbol '=' term ';' {
struct symbol *sym = cf_define_symbol($2, SYM_VARIABLE | $1, offset, f_new_var(sym_->scope));
- $$ = f_new_inst(FI_VAR_INIT, $3, sym);
+ $$ = f_new_inst(FI_VAR_INIT, $4, sym);
}
+ | type symbol ';' {
+ struct symbol *sym = cf_define_symbol($2, SYM_VARIABLE | $1, offset, f_new_var(sym_->scope));
+ $$ = f_new_inst(FI_VAR_INIT0, sym);
+ }
+ ;
for_var:
type symbol { $$ = cf_define_symbol($2, SYM_VARIABLE | $1, offset, f_new_var(sym_->scope)); }
RESULT(T_BOOL, i, ipa_is_ip4(v1.val.ip));
}
+ /* Add initialized variable */
INST(FI_VAR_INIT, 1, 0) {
NEVER_CONSTANT;
ARG_ANY(1);
fstk->vcnt = pos + 1;
}
+ /* Add uninitialized variable */
+ INST(FI_VAR_INIT0, 0, 0) {
+ NEVER_CONSTANT;
+ SYMBOL;
+
+ /* New variable is always the last on stack */
+ uint pos = curline.vbase + sym->offset;
+ fstk->vstk[pos] = (struct f_val) { };
+ fstk->vcnt = pos + 1;
+ }
+
/* Set to indirect value prepared in v1 */
INST(FI_VAR_SET, 1, 0) {
NEVER_CONSTANT;
*/
function t_prefix6()
-prefix px;
{
+ prefix px;
px = 1020::/18;
bt_assert(format(px) = "1020::/18");
bt_assert(1020:3040:5060:: ~ 1020:3040:5000::/40);
*/
function t_ec()
-ec cc;
{
+ ec cc;
cc = (rt, 12345, 200000);
bt_assert(format(cc) = "(rt, 12345, 200000)");