Computation of FIRST set

"Ulrich Frank" <>
19 Feb 2006 02:01:45 -0500

          From comp.compilers

Related articles
Computation of FIRST set (Ulrich Frank) (2006-02-19)
Re: Computation of FIRST set (Ulrich Hobelmann) (2006-02-19)
| List of all articles for this month |

From: "Ulrich Frank" <>
Newsgroups: comp.compilers
Date: 19 Feb 2006 02:01:45 -0500
Keywords: LL(1), question
Posted-Date: 19 Feb 2006 02:01:45 EST

Hello NG,

I have a big problem with ANTLR and the computation of the first set of
a rule. I've already read corresponing articles on the computation of
the first set but additionally want to ask you.

In the lexer I define a token ID : ('a'..'z'); and in the parser I have
the following rules:

rule1 = ID rule2 | rule2;
rule2 = "where" rule3;
rule3 ...

So FIRST(rule1) = {ID, "where"} and FIRST(rule2) = {"where"}

And if I define rule1 as

rule1 = (ID)? rule2;

which is equivalent to the first rule1 definition, FIRST(rule1) also is
{ID, "where"} RIGHT?!!

Please say, that I'm right. Thanks.

Post a followup to this message

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