help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: help with an if rule!


From: Hans Aberg
Subject: Re: help with an if rule!
Date: Sun, 14 Aug 2005 22:37:34 +0200


On 14 Aug 2005, at 21:43, Roberto Mandall wrote:

thx for the answer,but i still get errors, i guess i just do not undertsnad bison well enough.
i have this now:
%nonassoc ELSE
%nonassoc THEN

open_if_statement : IF boolean_expression {} THEN  statement {/}
|IF boolean_expression {} THEN closed_statement ELSE open_statement{} ; closed_if_statement : IF boolean_expression {} THEN closed_statement ELSE closed_statement {};


i get this:
bison -d --debug -v parser.y
parser.y: conflicts: 1 reduce/reduce

parser out put says:
State 140 conflicts: 1 reduce/reduce

state 140 has got this:

state 140

  38 statement: closed_statement .
54 open_if_statement: IF boolean_expression THEN closed_statement . @13 ELSE open_statement 56 closed_if_statement: IF boolean_expression THEN closed_statement . @14 ELSE closed_statement

   ELSE      reduce using rule 53 (@13)
   ELSE      [reduce using rule 55 (@14)]
   $default  reduce using rule 38 (statement)

   @13  go to state 162
   @14  go to state 163

can any1 plz tell me what am i doing wrong? i do really need those semantic rules after the "THEN closed_statement"

You have put a series of mid-rule actions, which causes reduce/reduce conflicts, as implemented as an empty rule. The token precedences just looks at the tokens immediately before and after the ".", and cannot resolve that. So you have to remove those mid-rule actions, putting the actions in the rules of the grammar variables preceding them.

  Hans Aberg






reply via email to

[Prev in Thread] Current Thread [Next in Thread]