GATE Computer ScienceModerateGATE CSE · NIELIT

For the grammar S → A B c; A → a A | ε; B → b B | ε, how many terminals are in FIRST(S)?

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

Correct answer: D. 3

FIRST(S) = FIRST(A) ∪ FIRST(B) ∪ {c} = {a, b, c} since A and B are nullable, so 3.

More Compiler Design questions

Exams that ask this topic