GATE Computer ScienceModerateGATE CS (PYQ pattern)

Which of the following is/are true? I. An LL(1) grammar can contain ε-productions. II. An LL(1) grammar is never ambiguous. III. If FIRST sets of the alternatives of every non-terminal are pairwise disjoint, the grammar is LL(1). IV. A left-recursive grammar can be LL(1) if its FOLLOW sets are disjoint.

  1. A. I, II and III only
  2. B. I and II only
  3. C. II and III only
  4. D. I, II and IV only

Correct answer: B. I and II only

I and II are true. III is false: nullable alternatives also need FIRST(α) ∩ FOLLOW(A) = ∅. IV is false: left recursion makes FIRST sets of alternatives overlap, so no left-recursive grammar is LL(1).

More Compiler Design questions

Exams that ask this topic