GATE Computer ScienceHardGATE CS (PYQ pattern)
An SLR(1) shift-reduce parser for E → T E'; E' → + T E' | ε; T → F T'; T' → * F T' | ε; F → ( E ) | id parses "id + id * id". Each shift and each reduce counts as one move. What are the grammar symbols on the parser stack (bottom to top) right after move number 9? (Initial state excluded.)
- A. T + F * id
- B. T + F *
- C. T + F * F
- D. T + F * F T'
Correct answer: A. T + F * id
Simulating the SLR table move by move, the stack after move 9 holds: T + F * id.
More Compiler Design questions
- Backpatching scheme (each relation gives 'if r goto ' and 'goto ', no fall-through optimisation, instruction numbers from 100). How many…
- A basic block compiles to six three-address statements: t1 = a + b; t2 = c d; t3 = a + b; t4 = t1 t2; t5 = t3 − t4; x = t5. Value…
- After applying left factoring repeatedly (each time extracting the longest common prefix of alternatives that share a first symbol…
- Consider the grammar S → A B c, A → a A | ε, B → b B | A d | ε. How many terminals are in FOLLOW(A), and is the grammar LL(1)?
- For the grammar S → A B, A → a A | a, B → b, the augmented canonical LR(0) collection has how many states, and what is the strongest class…
- In the expression a = (b + c) (b + c) - d / (b + c), the numbers of operator (internal) nodes in the syntax tree for the right-hand side…