summaryrefslogtreecommitdiff
path: root/filter
diff options
context:
space:
mode:
authorMartin Mares <mj@ucw.cz>1999-12-02 14:04:44 +0000
committerMartin Mares <mj@ucw.cz>1999-12-02 14:04:44 +0000
commit430da60fa29196cf8715e09e1d81c7ea0b672f05 (patch)
treed610f309e63a5243975e312f8be17c0b8422914c /filter
parentf2c6c80a2422b87a2947b7324ad14309198d64a4 (diff)
Implemented `show route where <condition>' command.
Pavel, please check my addition to filter/config.Y.
Diffstat (limited to 'filter')
-rw-r--r--filter/config.Y28
1 files changed, 26 insertions, 2 deletions
diff --git a/filter/config.Y b/filter/config.Y
index 05a0f2d2..5369468c 100644
--- a/filter/config.Y
+++ b/filter/config.Y
@@ -34,13 +34,13 @@ CF_KEYWORDS(FUNCTION, PRINT, PRINTN, CONST, UNSET,
LEN,
DEFINED,
IMPOSSIBLE,
- FILTER)
+ FILTER, WHERE)
%nonassoc THEN
%nonassoc ELSE
%type <x> term block cmds cmd function_body constant print_one print_list var_list var_listn any_dynamic
-%type <f> filter filter_body
+%type <f> filter filter_body where_filter
%type <i> type break_command pair
%type <e> set_item set_items switch_body
%type <v> set_atom prefix prefix_s ipa
@@ -124,6 +124,30 @@ filter:
| filter_body
;
+where_filter:
+ WHERE term {
+ /* Construct 'IF term THEN ACCEPT; REJECT;' */
+ struct filter *f = cfg_alloc(sizeof(struct filter));
+ struct f_inst *i, *acc, *rej;
+ acc = f_new_inst(); /* ACCEPT */
+ acc->code = 'p,';
+ acc->a1.p = NULL;
+ acc->a2.i = F_ACCEPT;
+ rej = f_new_inst(); /* REJECT */
+ rej->code = 'p,';
+ rej->a1.p = NULL;
+ rej->a2.i = F_REJECT;
+ i = f_new_inst(); /* IF */
+ i->code = '?';
+ i->a1.p = $2;
+ i->a2.p = acc;
+ i->next = rej;
+ f->name = NULL;
+ f->root = i;
+ $$ = f;
+ }
+ ;
+
function_params:
'(' declsn ')' { printf( "Have function parameters\n" ); $$=$2; }
| '(' ')' { $$=NULL; }