|Solving a shift/reduce conflict with an explicit precedence firstname.lastname@example.org (Paul Davis) (2003-07-23)|
|Re: Solving a shift/reduce conflict with an explicit precedence email@example.com (2003-07-25)|
|Re: Solving a shift/reduce conflict with an explicit precedence derkgwen@HotPOP.com (Derk Gwen) (2003-07-25)|
|From:||firstname.lastname@example.org (Hans Aberg)|
|Date:||25 Jul 2003 21:14:48 -0400|
|Posted-Date:||25 Jul 2003 21:14:48 EDT|
Paul Davis <email@example.com> wrote:
>I'm having a problem getting rid of a shift/reduce conflict in Bison,
>and would appreciate advice on how to set some precedences to do this.
>My basic problem is that, for simplicity, I have an ambiguous syntax.
>This will never cause a problem in real usage, but I can't convince
>Bison of that. ...
The way LR algorithms, like the LALR(1) used by Bison, resolves
shift/reduce conflicts is by looking at the precedences/associativity of
the two tokens before/after the . in the conflicting shift/reduce items.
Thus, a look at the state with the shift/reduce conflict below suggests
that you should try to set a precedence relation between the '=' and NAME
token. For some reason, you seem to not have tried that one.
I described the details of this conflict resolving method in a recent post
in this newsgroup.
> I have rules of the form:
State 282 contains 1 shift/reduce conflict.
dummy -> NAME '=' . const_expr (rule 115)
dummy -> NAME '=' . NAME (rule 116)
NAME shift, and go to state 346
NAME [reduce using rule 221 (@15)]
$default reduce using rule 221 (@15)
const_expr go to state 347
@15 go to state 60
Hans Aberg * Anti-spam: remove "remove." from email address.
* Email: Hans Aberg <firstname.lastname@example.org>
* Home Page: <http://www.math.su.se/~haberg/>
* AMS member listing: <http://www.ams.org/cml/>
Return to the
Search the comp.compilers archives again.