A canonical set of items is given below ܴ \(S \to L .> R\) \(Q \to R.\) On…
2014
A canonical set of items is given below ܴ
\(S \to L .> R\)
\(Q \to R.\)
On input symbol < the set has
- A.
a shift-reduce conflict and a reduce-reduce conflict.
- B.
a shift-reduce conflict but not a reduce-reduce conflict.
- C.
a reduce-reduce conflict but not a shift-reduce conflict.
- D.
neither a shift-reduce nor a reduce-reduce conflict.
Attempted by 99 students.
Show answer & explanation
Correct answer: D
Answer: neither a shift-reduce nor a reduce-reduce conflict.
Explanation:
Identify the actions suggested by the items: the item with the dot before '<' indicates a possible shift on input '<'.
Check the completed item: the completed production is an LR(1) item and therefore has an associated lookahead set. That lookahead does not include '<', so a reduction by this production is not allowed when the next input symbol is '<'.
Conclude about conflicts: because reduction is not applicable on '<', there is no shift-reduce conflict. Since there is only one completed production in the set, there are not two competing reductions, so there is no reduce-reduce conflict.
Therefore the canonical set has neither a shift-reduce nor a reduce-reduce conflict.
A video solution is available for this question — log in and enroll to watch it.