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?
- A. 1
- B. 2
- C. 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.
Practise more Theory of Computation, Compilers & Digital Logic (ISRO CS) questionsTheory of Computation, Compilers & Digital Logic (ISRO CS): notes and key points
More Theory of Computation, Compilers & Digital Logic (ISRO CS) questions
- An operator grammar is one in which no production right-hand side contains
- An LL(1) grammar has 4 non-terminals and 5 terminals. The predictive parsing table (with the end marker as an extra column) has how many…
- Live variable analysis is a data-flow problem of which type?
- Available expressions analysis is a data-flow problem of which type?
- Moving a computation whose value does not change inside a loop to before the loop is called
- A language accepted by some Turing machine (which may loop on strings outside the language) is called