GATE CS 2025 Set 2 | Question 40
Compiler Design › Parser · MCQ · 2 marks · Answer: C
- Question 40Compiler Designmcq2 marksGiven a CFG : . Which ONE of the following statements is TRUE?
- A.is neither LALR(1) nor SLR(1)
- B.is CLR(1), not LALR(1)
- C.is LALR(1), not SLR(1)✓
- D.is LALR(1), also SLR(1)
Answer: C
Solution
Answer: (C) is LALR(1), not SLR(1) This is a classic example. After reading there is a state with items for reducing and shifting (from ). Under SLR, the reduce is tried on all of , and also allows a shift, causing a shift-reduce conflict — so is not SLR(1). With LR(1)/LALR(1) lookaheads, the reduce is restricted to the specific contexts (lookaheads) that do not include the conflicting , resolving the conflict. So is LALR(1) but not SLR(1). - A.
More GATE PYQ on Parser
All GATE CS Compiler Design PYQ →Attempt GATE CS 2025 Set 2 in real GATE exam mode
Full paper with a timer, the GATE interface and a topic-wise analysis — free.
Create free account →