GATE Computer ScienceVery hardGATE CSE · UGC NET

How many of these four grammars are LL(1)? (1) S → a S b | ε; (2) S → A B; A → a | ε; B → a | b; (3) S → a A | b; A → S c | ε; (4) S → S a | b.

  1. A. 3
  2. B. 1
  3. C. 2
  4. D. 4

Correct answer: C. 2

Grammar 1 and 3 are LL(1); grammar 2 has A → a and A → ε both predicted on a (FOLLOW(A) contains a), and grammar 4 is left-recursive.

More Compiler Design questions

Exams that ask this topic