From 4995564570f9779686f767ec98034ce58d836203 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Wed, 10 Nov 1999 13:05:57 +0000 Subject: Shift/reduce conflicts in IF/THEN/ELSE rules solved. --- filter/config.Y | 32 ++++++++++++++------------------ 1 file 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 term block cmds cmd function_body ifthen constant print_one print_list var_list var_listn any_dynamic +%type term block cmds cmd function_body constant print_one print_list var_list var_listn any_dynamic %type filter filter_body %type type break_command pair %type 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(); -- cgit v1.2.3