diff options
Diffstat (limited to 'conf/confbase.Y')
-rw-r--r-- | conf/confbase.Y | 49 |
1 files changed, 32 insertions, 17 deletions
diff --git a/conf/confbase.Y b/conf/confbase.Y index 3fd034db..dcc92365 100644 --- a/conf/confbase.Y +++ b/conf/confbase.Y @@ -49,13 +49,17 @@ CF_DECLS struct rtable_config *r; struct channel_config *cc; struct f_inst *x; + struct f_inst *xp[2]; + enum filter_return fret; + enum ec_subtype ecs; struct f_dynamic_attr fda; struct f_static_attr fsa; - struct filter *f; + struct f_lval flv; + const struct f_line *fl; + const struct filter *f; struct f_tree *e; struct f_trie *trie; struct f_val v; - struct f_path_mask *h; struct password_item *p; struct rt_show_data *ra; struct sym_show_data *sd; @@ -78,7 +82,7 @@ CF_DECLS %token <ip4> IP4 %token <ip6> IP6 %token <i64> VPN_RD -%token <s> SYM +%token <s> CF_SYM_VOID CF_SYM_PROTO CF_SYM_TEMPLATE CF_SYM_FUNCTION CF_SYM_FILTER CF_SYM_TABLE CF_SYM_ATTRIBUTE CF_SYM_VARIABLE CF_SYM_CONSTANT %token <t> TEXT %type <iface> ipa_scope @@ -90,6 +94,7 @@ CF_DECLS %type <mls> label_stack_start label_stack %type <t> text opttext +%type <s> symbol %nonassoc PREFIX_DUMMY %left AND OR @@ -122,29 +127,39 @@ conf: ';' ; conf: definition ; definition: - DEFINE SYM '=' term ';' { + DEFINE CF_SYM_VOID '=' term ';' { struct f_val *val = cfg_alloc(sizeof(struct f_val)); - *val = f_eval($4, cfg_mem); - if (val->type == T_RETURN) cf_error("Runtime error"); - cf_define_symbol($2, SYM_CONSTANT | val->type, val); + if (f_eval(f_postfixify($4), cfg_mem, val) > F_RETURN) cf_error("Runtime error"); + cf_define_symbol($2, SYM_CONSTANT | val->type, val, val); } ; expr: NUM - | '(' term ')' { $$ = f_eval_int($2); } - | SYM { + | '(' term ')' { $$ = f_eval_int(f_postfixify($2)); } + | CF_SYM_CONSTANT { if ($1->class != (SYM_CONSTANT | T_INT)) cf_error("Number expected"); $$ = SYM_VAL($1).i; } ; - expr_us: expr S { $$ = $1 S_; } | expr MS { $$ = $1 MS_; } | expr US { $$ = $1 US_; } ; +symbol: + CF_SYM_VOID + | CF_SYM_PROTO + | CF_SYM_TEMPLATE + | CF_SYM_FUNCTION + | CF_SYM_FILTER + | CF_SYM_TABLE + | CF_SYM_ATTRIBUTE + | CF_SYM_VARIABLE + | CF_SYM_CONSTANT + ; + /* Switches */ bool: @@ -162,7 +177,7 @@ bool: ipa: IP4 { $$ = ipa_from_ip4($1); } | IP6 { $$ = ipa_from_ip6($1); } - | SYM { + | CF_SYM_CONSTANT { if ($1->class != (SYM_CONSTANT | T_IP)) cf_error("IP address expected"); $$ = SYM_VAL($1).ip; } @@ -170,7 +185,7 @@ ipa: ipa_scope: /* empty */ { $$ = NULL; } - | '%' SYM { $$ = if_get_by_name($2->name); } + | '%' symbol { $$ = if_get_by_name($2->name); } ; @@ -277,7 +292,7 @@ net_: net_ip6: net_ip6_ - | SYM { + | CF_SYM_CONSTANT { if (($1->class != (SYM_CONSTANT | T_NET)) || (SYM_VAL($1).net->type != NET_IP6)) cf_error("IPv6 network expected"); $$ = * SYM_VAL($1).net; @@ -286,7 +301,7 @@ net_ip6: net_ip: net_ip_ - | SYM { + | CF_SYM_CONSTANT { if (($1->class != (SYM_CONSTANT | T_NET)) || !net_is_ip(SYM_VAL($1).net)) cf_error("IP network expected"); $$ = * SYM_VAL($1).net; @@ -295,7 +310,7 @@ net_ip: net_any: net_ - | SYM { + | CF_SYM_CONSTANT { if ($1->class != (SYM_CONSTANT | T_NET)) cf_error("Network expected"); $$ = (net_addr *) SYM_VAL($1).net; /* Avoid const warning */ @@ -307,7 +322,7 @@ net_or_ipa: | net_ip6_ | IP4 { net_fill_ip4(&($$), $1, IP4_MAX_PREFIX_LENGTH); } | IP6 { net_fill_ip6(&($$), $1, IP6_MAX_PREFIX_LENGTH); } - | SYM { + | CF_SYM_CONSTANT { if ($1->class == (SYM_CONSTANT | T_IP)) net_fill_ip_host(&($$), SYM_VAL($1).ip); else if (($1->class == (SYM_CONSTANT | T_NET)) && net_is_ip(SYM_VAL($1).net)) @@ -344,7 +359,7 @@ time: text: TEXT - | SYM { + | CF_SYM_CONSTANT { if ($1->class != (SYM_CONSTANT | T_STRING)) cf_error("String expected"); $$ = SYM_VAL($1).s; } |