GATE Computer ScienceVery hardGATE CS (PYQ pattern)

A SLR(1) parser for the augmented grammar S → x A | y B; A → z S | ε; B → z S | w parses "x z y w". What is the maximum number of grammar symbols on its stack at any moment (state numbers are not counted, S′ never appears)?

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

Correct answer: D. 4

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

More Compiler Design questions

Exams that ask this topic