GATE Computer ScienceHardGATE CSE · NIELIT
For S → L = R | R; L → * R | id; R → L, how many states of the LR(0) automaton contain a conflict that SLR(1) fails to resolve?
- A. 2
- B. 3
- C. 0
- D. 1
Correct answer: D. 1
In the state containing S → L . = R and R → L . the symbol = is in FOLLOW(R) (since L → * R and R → L put R wherever L can appear, and L is followed by =), so SLR(1) cannot decide between shifting = and reducing; this is the only such state, giving 1.
More Compiler Design questions
- For E → T E′; E′ → + T E′ | ε; T → F T′; T′ → F T′ | ε; F → ( E ) | id, what is the sum of the sizes of the FOLLOW sets of E, E′, T, T′…
- How many LR(0) items does the grammar S → a S b | S S | ε | c d have (the ε-production contributes one item; do not count the augmented…
- A basic block is: t1 = a + b; t2 = a − b; t3 = t1 t2; t4 = a + b; t5 = t4 t2; t6 = t3 + t5; y = t6 / t3. How many nodes (leaves included)…
- The interference graph of six variables v0–v5 has edges v0 with each of v1–v5, plus the cycle v1–v2–v3–v4–v5–v1. What is the minimum…
- Using E → E + T | T; T → T F | F; F → ( E ) | id, how many nodes (terminal leaves included) does the parse tree of id + id id id + id have?
- After local common-subexpression elimination, algebraic simplification (x + 0, x 1), copy propagation and dead-code elimination, how many…