summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Mares <mj@ucw.cz>1999-11-10 14:05:57 +0100
committerMartin Mares <mj@ucw.cz>1999-11-10 14:05:57 +0100
commit4995564570f9779686f767ec98034ce58d836203 (patch)
tree4a44e417e65879ee4873347e8a2fa2d1b358e684
parentf453665704cc8d946f86057e67151ef27419e280 (diff)
downloadbird-4995564570f9779686f767ec98034ce58d836203.tar
bird-4995564570f9779686f767ec98034ce58d836203.zip
Shift/reduce conflicts in IF/THEN/ELSE rules solved.
-rw-r--r--filter/config.Y32
1 files changed, 14 insertions, 18 deletions
diff --git a/filter/config.Y b/filter/config.Y
index a12766e..b410397 100644
--- a/filter/config.Y
+++ b/filter/config.Y
@@ -36,10 +36,10 @@ CF_KEYWORDS(FUNCTION, PRINT, PRINTN, CONST,
FILTER
)
+%nonassoc ELSE
%nonassoc THEN
-%nonassoc ELSE ';'
-%type <x> term block cmds cmd function_body ifthen constant print_one print_list var_list var_listn any_dynamic
+%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 <i> type break_command pair
%type <e> set_item set_items switch_body
@@ -213,7 +213,6 @@ set_items:
| set_items ',' set_item { $$ = $3; $$->left = $1; }
;
-/* 2 shift/reduce conflicts here. Curable by replacing cmds with block which breaks syntax */
switch_body: /* EMPTY */ { $$ = NULL; }
| set_item ':' cmds switch_body {
$$ = $1;
@@ -294,15 +293,6 @@ break_command:
| PRINTN { $$ = F_NONL }
;
-ifthen:
- IF term THEN block {
- $$ = f_new_inst();
- $$->code = '?';
- $$->a1.p = $2;
- $$->a2.p = $4;
- }
- ;
-
print_one:
term { $$ = f_new_inst(); $$->code = 'p'; $$->a1.p = $1; $$->a2.p = NULL; }
;
@@ -337,15 +327,21 @@ var_list: /* EMPTY */ { $$ = NULL; }
;
cmd:
- ifthen {
- $$ = $1;
+ IF term THEN block {
+ $$ = f_new_inst();
+ $$->code = '?';
+ $$->a1.p = $2;
+ $$->a2.p = $4;
}
- /* FIXME: this leads to shift/reduce conflict. */
- | ifthen ELSE block {
+ | IF term THEN block ELSE block {
+ struct f_inst *i = f_new_inst();
+ i->code = '?';
+ i->a1.p = $2;
+ i->a2.p = $4;
$$ = f_new_inst();
$$->code = '?';
- $$->a1.p = $1;
- $$->a2.p = $3;
+ $$->a1.p = i;
+ $$->a2.p = $6;
}
| SYM '=' term ';' {
$$ = f_new_inst();