GATE Computer ScienceVery hardGATE CS · ISRO

In S → A B C | C a; A → a A | ε; B → b B | A c | ε; C → d | B e, how many symbols (including $) does FOLLOW(B) contain?

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

Correct answer: D. 5

In S → A B C, B is followed by C, so FOLLOW(B) ⊇ FIRST(C) = {d} ∪ (FIRST(B) = {a, b, c}) ∪ {e}, where e comes from C → B e. Hence FOLLOW(B) = {a, b, c, d, e}, 5 symbols; $ is not included because C is not nullable.

More Compiler Design questions

Exams that ask this topic