|Newbie: Does an LR(k) parser compute the FIRST set? email@example.com (Ulrich Frank) (2006-02-12)|
|Re: Newbie: Does an LR(k) parser compute the FIRST set? firstname.lastname@example.org (Sylvain Schmitz) (2006-02-14)|
|Newbie: Does an LR(k) parser compute the FIRST set? email@example.com (Etienne Gagnon) (2006-02-14)|
|Re: Newbie: Does an LR(k) parser compute the FIRST set? firstname.lastname@example.org (Ulrich Frank) (2006-02-14)|
|From:||Sylvain Schmitz <email@example.com>|
|Date:||14 Feb 2006 10:15:56 -0500|
|Keywords:||LALR, parse, comment|
|Posted-Date:||14 Feb 2006 10:15:56 EST|
Ulrich Frank wrote:
> - Does a LR-Parser also compute the FIRST and FOLLOW sets like a
Only the FIRST sets are needed for LR(k), k>0, parser construction: the
computation of the lookahead uses them. The basic LR(0) construction
does not use any of these sets. SLR parsers need to compute the FIRST
and FOLLOW sets. LALR parsers do not need any of these sets, but need
to compute which nonterminals are nullable.
> So far I used ANTLR for generating a grammar. I've chosen ANTLR
> because I need to analyse the FIRST set.
What exactly made this analysis of the FIRST sets mandatory? LR parsers
handle more grammars than LL ones, thus if your issue was related to
parsing conflict resolution, there is a slight chance for this analysis
to be unnecessary with LR parsers.
> Now I've read that LR-Parsers are much more efficient and faster
> than LL-Parsers, so I want to change [...].
If you have a working software using ANTLR, I am not sure that the
potential efficiency you might win will be worth rewriting for another
Hope that helps,
[It's been a long time since I saw a compiler where the parser was a
bottleneck. The usual performance hogs are character processing in the
lexer and global analysis in the optimizer. -John]
Return to the
Search the comp.compilers archives again.