Re: LR(1) resolving SLR(1) reduce/reduce conflict

haberg@math.su.se (Hans Aberg)
31 Mar 2003 13:41:18 -0500

          From comp.compilers

Related articles
LR(1) resolving SLR(1) reduce/reduce conflict haberg@math.su.se (2003-03-30)
Re: LR(1) resolving SLR(1) reduce/reduce conflict gvcormac@speedy.uwaterloo.ca (2003-03-30)
Re: LR(1) resolving SLR(1) reduce/reduce conflict haberg@math.su.se (2003-03-31)
Re: LR(1) resolving SLR(1) reduce/reduce conflict gvcormac@speedy.uwaterloo.ca (2003-04-05)
Re: LR(1) resolving SLR(1) reduce/reduce conflict haberg@math.su.se (2003-04-07)
| List of all articles for this month |

From: haberg@math.su.se (Hans Aberg)
Newsgroups: comp.compilers
Date: 31 Mar 2003 13:41:18 -0500
Organization: Mathematics
Keywords: parse, LR(1)
Posted-Date: 31 Mar 2003 13:41:18 EST

gvcormac@speedy.uwaterloo.ca (Gordon Cormack) wrote:


>The following grammar is LR(1) but not SLR(1) or LALR(1)
>
> S -> A x B x
> S -> B y A y
> A -> w
> B -> w


Thank for the example!


>LR(1) has two different states:
>
> A -> w . { x }
> A -> w . { y }
>
>and
>
> A -> w . { y }
> A -> w . { x }


I got three LR(1) states:
        1. A -> w . {x}
              B -> w . {y}


        2. A -> w . {y}


        3. B -> w . {x}


Somehow, you have merged states 2 and 3 above. Perhaps that is what
happens in LALR(1)?


In SLR, just drop the {..} lookaheads.


    Hans Aberg * Anti-spam: remove "remove." from email address.
                                    * Email: Hans Aberg <remove.haberg@member.ams.org>
                                    * Home Page: <http://www.math.su.se/~haberg/>
                                    * AMS member listing: <http://www.ams.org/cml/>


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.