Computer Science EngineeringVery hard

For the grammar E -> E + E | id, how many reduce actions does a shift-reduce parser perform while parsing id + id?

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

Correct answer: D. 3

It reduces each id to E (twice) and then reduces E + E to E once, making 3 reductions.

More Theory of Computation, Compilers & Digital Logic (ISRO CS) questions

Exams that ask this topic