Re: power of SLR

"J.H.Jongejan" <jjan@cs.rug.nl>
20 Sep 2001 00:27:09 -0400

          From comp.compilers

Related articles
power of SLR thant@acm.org (Thant Tessman) (2001-09-16)
Re: power of SLR jjan@cs.rug.nl (J.H.Jongejan) (2001-09-20)
Re: power of SLR thant@acm.org (Thant Tessman) (2001-09-20)
Re: power of SLR blp@stanford.edu (Ben Pfaff) (2001-09-25)
| List of all articles for this month |

From: "J.H.Jongejan" <jjan@cs.rug.nl>
Newsgroups: comp.compilers
Date: 20 Sep 2001 00:27:09 -0400
Organization: Groningen University (NL)
References: 01-09-059
Keywords: parse
Posted-Date: 20 Sep 2001 00:27:09 EDT

Thant Tessman wrote:
>
> I've implemented the SLR parser generator described in Appel's "Modern
> Compiler Implementation in ML," but I've implemented it in C++. I
> chose SLR because it was the most clearly described technique.
>
> The parser generator seems to work on the example grammar in the book,
> but reports ambiguities in grammars like the canonical:
>
> E -> E - T
> E -> T
> T -> T / F
> T -> F
> F -> id
> F -> ( E )


This grammar is SLR(1). It contains two states with a shift/reduce
conflict. However they are solvable using follow information:
    E -> T. E -> E-T.
    T -> T./F T -> T./F
In both cases follow(E) does not contain the '/'.


--
Regards,


Jan Jongejan
Dept. Comp.Sci.,
Univ. of Groningen,
Netherlands.
email: jjan@cs.rug.nl


Post a followup to this message

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