diff options
author | Ondrej Zajicek <santiago@crfreenet.org> | 2014-10-14 17:23:34 +0200 |
---|---|---|
committer | Ondrej Zajicek <santiago@crfreenet.org> | 2014-10-14 17:23:34 +0200 |
commit | 78342404ff573e85e396f0611014b90cea9b4c0a (patch) | |
tree | 39fd70db506dc05d83528b7afab258b07b8ac482 /filter/config.Y | |
parent | 178a197afb77770d8a90765e39065679936a45d1 (diff) | |
parent | cfdea7b85f6c520cc5a62eb907d2190db14c9900 (diff) |
Merge remote-tracking branch 'origin/master' into soft-int
Diffstat (limited to 'filter/config.Y')
-rw-r--r-- | filter/config.Y | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/filter/config.Y b/filter/config.Y index 04acfbab..e50e75ca 100644 --- a/filter/config.Y +++ b/filter/config.Y @@ -25,6 +25,23 @@ static inline u32 pair_b(u32 p) { return p & 0xFFFF; } * to the last item in a list (right ptr). For convenience, even items * are handled as one-item lists. Lists are merged by f_merge_items(). */ +static int +f_valid_set_type(int type) +{ + switch (type) + { + case T_INT: + case T_PAIR: + case T_QUAD: + case T_ENUM: + case T_IP: + case T_EC: + return 1; + + default: + return 0; + } +} static inline struct f_tree * f_new_item(struct f_val from, struct f_val to) @@ -473,10 +490,19 @@ fipa: */ set_atom: - expr { $$.type = T_INT; $$.val.i = $1; } + NUM { $$.type = T_INT; $$.val.i = $1; } | RTRID { $$.type = T_QUAD; $$.val.i = $1; } | fipa { $$ = $1; } | ENUM { $$.type = pair_a($1); $$.val.i = pair_b($1); } + | '(' term ')' { + $$ = f_eval($2, cfg_mem); + if (!f_valid_set_type($$.type)) cf_error("Set-incompatible type"); + } + | SYM { + if (!cf_symbol_is_constant($1)) cf_error("%s: constant expected", $1->name); + if (!f_valid_set_type(SYM_TYPE($1))) cf_error("%s: set-incompatible type", $1->name); + $$ = *(struct f_val *)($1->def); + } ; switch_atom: |