diff options
author | Ondrej Zajicek <santiago@crfreenet.org> | 2010-02-02 00:03:46 +0100 |
---|---|---|
committer | Ondrej Zajicek <santiago@crfreenet.org> | 2010-02-02 00:03:46 +0100 |
commit | 5f47c4c11ed8da3415c4c8c247bf52ab6a48255d (patch) | |
tree | 43047df2d300af0268a59b8106d652e1d269282b | |
parent | 1a7a4e59a22f903a0be791f229e86ab881593851 (diff) | |
download | bird-5f47c4c11ed8da3415c4c8c247bf52ab6a48255d.tar bird-5f47c4c11ed8da3415c4c8c247bf52ab6a48255d.zip |
Changes right-recursion to left-recursion in a filter grammar.
Because we don't want to have a limit on a function/filter length.
-rw-r--r-- | filter/config.Y | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/filter/config.Y b/filter/config.Y index 22206d0..f8674e5 100644 --- a/filter/config.Y +++ b/filter/config.Y @@ -43,7 +43,7 @@ CF_KEYWORDS(FUNCTION, PRINT, PRINTN, UNSET, RETURN, %nonassoc THEN %nonassoc ELSE -%type <x> term block cmds cmd function_body constant print_one print_list var_list var_listn dynamic_attr static_attr function_call symbol dpair bgp_path_expr +%type <x> term block cmds cmds_int cmd function_body constant print_one print_list var_list var_listn dynamic_attr static_attr function_call symbol dpair bgp_path_expr %type <f> filter filter_body where_filter %type <i> type break_command cpair %type <e> set_item set_items switch_body @@ -191,15 +191,15 @@ function_def: /* Programs */ +/* Hack: $$ of cmds_int is the last node. + $$->next of cmds_int is temporary used for the first node */ + cmds: /* EMPTY */ { $$ = NULL; } - | cmd cmds { - if ($1) { - if ($1->next) - bug("Command has next already set"); - $1->next = $2; - $$ = $1; - } else $$ = $2; - } + | cmds_int { $$ = $1->next; $1->next = NULL; } + ; + +cmds_int: cmd { $$ = $1; $1->next = $1; } + | cmds_int cmd { $$ = $2; $2->next = $1->next ; $1->next = $2; } ; block: |