help-bison
[Top][All Lists]
Advanced

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

RE: Why Bison prefer reduce to shift in dangling else?


From: John Madsen
Subject: RE: Why Bison prefer reduce to shift in dangling else?
Date: Mon, 24 Feb 2003 22:13:06 -0500

> Subject: RE: Why Bison prefer reduce to shift in dangling else?
> 
> 
> Thank you. I added %nonassoc THEN %nonassoc ELSE to my 
> grammar for the Tiger langauge. Attached. The bison still 
> chooses reduce rather than shift. The first line of the 
> tiger.output reads "Conflict in state 104 between rule 25 and 
> token ELSE resolved as shift." but under state 104, i found
> 
>       state 104
> 
>               exp  ->  IF vexp THEN exp .   (rule 25)
>               exp  ->  IF vexp THEN exp . ELSE exp   (rule 26)
> 
>               ELSE    shift, and go to state 123
> 
>               $default        reduce using rule 25 (exp)
> 
> It is frustrating. Any help will be appreciated.
> 
> Lunjin Lu

I think you're misinterpreting what Bison is telling you.  It *is*
choosing shift on ELSE.  The last two lines from state 104 mean that if
it sees ELSE next, it shifts, otherwise ($default) it reduces.  Also,
what version of Bison are you using?  When I ran your grammar through
1.875a, I got no conflicts.

HTH,

John Madsen





reply via email to

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