GATE 2022 CS – Question 29
Consider the augmented grammar with $\{+, *, (, ), id\}$ as the set of terminals.
$S'\to S$
$S\to S+R\mid R$
$R\to R*P\mid P$
$P\to (S)\mid id$
If $I_0$ is the set of two $LR(0)$ items $\{[S'\to S.],[S\to S.+R]\}$, then $goto(closure(I_0),+)$ contains exactly __________ items.
Practise this question in The GATE Grind →
Show answer and explanation
Correct answer: 5
Explanation
goto on + gives $S\to S+.R$. Closure adds $R\to .R*P$, $R\to .P$, $P\to .(S)$ and $P\to .id$, for a total of 5 items.