diff options
author | Pavel Machek <pavel@ucw.cz> | 2000-04-20 12:25:51 +0200 |
---|---|---|
committer | Pavel Machek <pavel@ucw.cz> | 2000-04-20 12:25:51 +0200 |
commit | 7d6eebae3b87cac2d09fd5201b603d4fd969fe06 (patch) | |
tree | 15802c4cf188919cf9b4af76b57dc172dd196f67 /filter | |
parent | 77f37ae0994774f6402499e0a79287d85afa6edf (diff) | |
download | bird-7d6eebae3b87cac2d09fd5201b603d4fd969fe06.tar bird-7d6eebae3b87cac2d09fd5201b603d4fd969fe06.zip |
Create syntax sugar for add/delete/prepend, so xyzzy.prepend(123) is
possible. That means that milestone 3 was reached.
Diffstat (limited to 'filter')
-rw-r--r-- | filter/config.Y | 7 | ||||
-rw-r--r-- | filter/f-util.c | 23 |
2 files changed, 30 insertions, 0 deletions
diff --git a/filter/config.Y b/filter/config.Y index 3396669..f33405f 100644 --- a/filter/config.Y +++ b/filter/config.Y @@ -550,6 +550,13 @@ cmd: $$->a1.p = $2; $$->a2.p = build_tree( $4 ); } + + + | rtadot dynamic_attr '.' EMPTY ';' + { struct f_inst *i = f_new_inst(); i->code = 'E'; i->aux = T_CLIST; $$ = $2; $$->code = P('e','S'); $$->a1.p = i; } + | rtadot dynamic_attr '.' PREPEND '(' term ')' ';' { $$ = f_generate_complex( P('A','p'), 'x', $2, $6 ); } + | rtadot dynamic_attr '.' ADD '(' term ')' ';' { $$ = f_generate_complex( P('C','a'), 'a', $2, $6 ); } + | rtadot dynamic_attr '.' DELETE '(' term ')' ';' { $$ = f_generate_complex( P('C','a'), 'd', $2, $6 ); } ; CF_END diff --git a/filter/f-util.c b/filter/f-util.c index cf174e7..ba6e777 100644 --- a/filter/f-util.c +++ b/filter/f-util.c @@ -10,6 +10,8 @@ #include "conf/conf.h" #include "filter/filter.h" +#define P(a,b) ((a<<8) | b) + struct f_inst * f_new_inst(void) { @@ -29,6 +31,27 @@ f_new_dynamic_attr(int type, int f_type, int code) return f; } +/* + * Generate set_dynamic( operation( get_dynamic(), argument ) ) + */ +struct f_inst * +f_generate_complex(int operation, int operation_aux, struct f_inst *dyn, struct f_inst *argument) +{ + struct f_inst *set_dyn = f_new_inst(), + *oper = f_new_inst(), + *get_dyn = dyn; + + *set_dyn = *get_dyn; + get_dyn->code = P('e','a'); + oper->code = operation; + oper->aux = operation_aux; + oper->a1.p = get_dyn; + oper->a2.p = argument; + set_dyn->code = P('e','S'); + set_dyn->a1.p = oper; + return set_dyn; +} + char * filter_name(struct filter *filter) { |