GATE Computer ScienceHardGATE CS (PYQ pattern)

An SLR(1) shift-reduce parser for E → E + T | T; T → T * F | F; F → ( E ) | id parses "( id + id ) * id". Each shift and each reduce counts as one move. What are the grammar symbols on the parser stack (bottom to top) right after move number 8? (Initial state excluded.)

  1. A. ( E + id
  2. B. ( E + F
  3. C. ( E + T
  4. D. ( E

Correct answer: B. ( E + F

Simulating the SLR table move by move, the stack after move 8 holds: ( E + F.

More Compiler Design questions

Exams that ask this topic