Re: SLR and LR(1) Differences: A Recap

"Vladimir Lushnikov" <vladimir.d.lushnikov@gmail.com>
18 Aug 2006 01:11:22 -0400

          From comp.compilers

Related articles
SLR and LR(1) Differences: A Recap vladimir.d.lushnikov@gmail.com (Vladimir Lushnikov) (2006-08-10)
Re: SLR and LR(1) Differences: A Recap momchil.velikov@gmail.com (momchil.velikov@gmail.com) (2006-08-12)
Re: SLR and LR(1) Differences: A Recap torbenm@app-4.diku.dk (2006-08-14)
Re: SLR and LR(1) Differences: A Recap vladimir.d.lushnikov@gmail.com (Vladimir Lushnikov) (2006-08-18)
Re: SLR and LR(1) Differences: A Recap luvisi@andru.sonoma.edu (Andru Luvisi) (2006-08-19)
Re: SLR and LR(1) Differences: A Recap rda@lemma-one.com (Rob Arthan) (2006-10-03)
| List of all articles for this month |

From: "Vladimir Lushnikov" <vladimir.d.lushnikov@gmail.com>
Newsgroups: comp.compilers
Date: 18 Aug 2006 01:11:22 -0400
Organization: http://groups.google.com
References: 06-08-05506-08-077
Keywords: LR(1), parse

Torben Ęgidius Mogensen wrote:
> "Vladimir Lushnikov" <vladimir.d.lushnikov@gmail.com> writes:
>
>
> > I guess my question is how the SLR tables are constructed compared to
> > LR(1) tables and how they differ?
>
> I won't go into details, as you can pick those up in most compiler
> textbooks (such as the old "Dragon Book" by Aho, Sethi & Ullman).
>
> A more relevant question for compiler writers is "does it matter?".
> IMO, it matters little -- while LR(1) (or LALR(1)) might resolve some
> conflicts that SLR parsers do not, you do not escape the need to
> rewrite your grammer to avoid conflicts, and in my experience the
> cases where LR(1) makes this easier are few.
>
> LR(1) parse tables are much larger than SLR, whereas LALR(1) tables
> are no bigger. That makes LALR(1) popular for parser generators, and
> you can argue that this makes SLR uninteresting. I have, however,
> found that most people think in terms of FOLLOW when resolving
> conflicts in LALR(1) parsers, so they might as well be SLR.
>
> In short, I think the advantages of LALR(1) and LR(1) over SLR are
> overrated. I do, however, find that SLR (or the other LR variants) is
> much easier to use than LL(1), partly because it doesn't require left
> recursion removal and left-factoring and partly because SLR handles
> operator precedence more easily.


I agree, the reason I was asking is to clarify (the seemingly trivial)
distinction between constructing SLR and LR(1) tables because I am
trying to see whether there would be any difference if the tables were
used (with an ambiguous grammar) in a GLR parsing algorithm.



Post a followup to this message

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