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

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top