GATE Computer ScienceHardGATE CS (PYQ pattern)

For S → A B | B C; A → a A | ε; B → b B | ε; C → c C | d, which statement is FALSE?

  1. A. FOLLOW(B) = {c, d, $}
  2. B. M[S, b] holds both S-productions
  3. C. FIRST(S) = {a, b, c, d, ε}
  4. D. M[S, $] holds both S-productions

Correct answer: D. M[S, $] holds both S-productions

A and B are nullable, C is not; M[C, c] and M[C, d] each hold one production. FIRST(A B) = {a, b, ε} and FIRST(B C) = {b, c, d}, so FIRST(S) = {a, b, c, d, ε} and both S-productions meet in M[S, b]. FOLLOW(B) = FOLLOW(S) ∪ FIRST(C) = {$, c, d}. But only S → A B is nullable, so M[S, $] holds just S → A B: that statement is false.

More Compiler Design questions

Exams that ask this topic