Question

I am currently reading the Dragon Book in my free time. The book states that a grammar is LL if and only if for any production A -> a|b, the following two conditions apply.

1) FIRST(a) and FIRST(b) are disjoint. This implies that they cannot both derive EMPTY

2) If 'b' can derive EMPTY, then 'a' cannot derive any string that begins with FOLLOW(A)

I know that LL parsers cannot handle left recursion in general, but if I make a grammar

S -> S(S) | EMPTY,

FIRST(S) = {'('} and FOLLOW(S) = {EOF}. This does not seem to contradict any of the two rules, am I missing something?

Thank you in advance, Michael

Était-ce utile?

La solution

It has been a while, but I think FOLLOWS(S) = {EOF,')','('}.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top