GATE Computer ScienceEasyGATE CS (PYQ pattern)

A table-driven LL(1) parser for S → ( S ) S | ε parses "( ) ( )". Each pop of a non-terminal (expanding it) and each match of a terminal is one move. How many moves does it make before reaching $ on both stack and input?

  1. A. 5
  2. B. 10
  3. C. 9
  4. D. 11

Correct answer: C. 9

5 expansions and 4 terminal matches (including expansions to ε) give 9 moves.

More Compiler Design questions

Exams that ask this topic