[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: Why Bison prefer reduce to shift in dangling else?
From: |
Hans Aberg |
Subject: |
RE: Why Bison prefer reduce to shift in dangling else? |
Date: |
Tue, 25 Feb 2003 10:56:45 +0100 |
At 22:13 -0500 2003/02/24, John Madsen wrote:
>> 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.
Right: it looks as a misunderstanding.
If the order of the two %nonassoc is changed, ELSE should become reduce.
But the normal in computer languages is to have it as shift.
> Also,
>what version of Bison are you using? When I ran your grammar through
>1.875a, I got no conflicts.
It should not have anything with that to do.
Hans Aberg
Re: Why Bison prefer reduce to shift in dangling else?, Akim Demaille, 2003/02/25
RE: Why Bison prefer reduce to shift in dangling else?, Lunjin Lu, 2003/02/25