GATE 2025 CS (CS2) – Question 40
Given a Context-Free Grammar $G$ as follows:
$S \to Aa \mid bAc \mid dc \mid bda$
$A \to d$
Which ONE of the following statements is TRUE?
Practise this question in The GATE Grind →
Show answer and explanation
Correct answer: (C) $G$ is LALR(1), not SLR(1)
Explanation
In the state containing $S \to d.c$ and $A \to d.$, SLR reduces on FOLLOW(A) = {a, c}, which conflicts with the shift on c. In LR(1)/LALR(1) the lookahead for that reduction is only 'a', and the state after 'bd' has different cores, so no states merge and there is no conflict.