GATE Computer ScienceEasyGATE CS (PYQ pattern)

For the grammar S → X Y Z; X → a X | ε; Y → b Y | X; Z → c | ε, what is FIRST(S)? (ε counts as a member if S is nullable.)

  1. A. {$, a, b, c, ε}
  2. B. {a, b, c}
  3. C. {a, b, ε}
  4. D. {a, b, c, ε}

Correct answer: D. {a, b, c, ε}

S → X Y Z with X, Y and Z all nullable (Y can derive X, which can derive ε, and Z → ε), so FIRST(S) collects a, b, c and also ε.

More Compiler Design questions

Exams that ask this topic