GATE Computer ScienceModerateGATE CS (PYQ pattern)

For the grammar S → A B; A → a | ε; B → A b | c, what is FOLLOW(A)?

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

Correct answer: B. {a, b, c}

A occurs in S → A B, where FIRST(B) = {a, b, c} (B → A b can start with a, or with b when A is empty, or with c), and B is not nullable; in B → A b it adds b. So FOLLOW(A) = {a, b, c}.

More Compiler Design questions

Exams that ask this topic