GATE Computer ScienceVery hardGATE CS (PYQ pattern)

A SLR(1) parser for the augmented grammar S → id | id [ E ] | id ( E ); E → id parses "id [ id ]". What is the maximum number of grammar symbols on its stack at any moment (state numbers are not counted, S′ never appears)?

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

Correct answer: A. 4

Tracking the stack through 4 shifts and 2 reductions, the peak height is 4.

More Compiler Design questions

Exams that ask this topic