GATE Computer ScienceHardGATE CS (PYQ pattern)

Build the LL(1) table for E → T R; R → + T R | − T R | ε; T → F P; P → ^ T | ε; F → ( E ) | id (^ is right-associative exponent). How many cells are non-blank, and how many of those hold an ε-production?

  1. A. 15 and 4
  2. B. 15 and 6
  3. C. 13 and 6
  4. D. 17 and 8

Correct answer: B. 15 and 6

FOLLOW(E) = FOLLOW(R) = {$, )}; FOLLOW(T) = FIRST(R) − ε ∪ FOLLOW(R) = {+, −, $, )} and FOLLOW(P) = FOLLOW(T) (P → ^ T ends with T). Non-blank: E 2, R 4 (+, −, $, )), T 2, P 5 (^ and the 4 of FOLLOW(P)), F 2 = 15. ε-entries: R → ε in 2 cells, P → ε in 4 cells = 6.

More Compiler Design questions

Exams that ask this topic