The GATE Grind

GATE 2024 CS (CS2) – Question 65

Compiler Design · Parsing and Syntax Analysis · 2 marks · Numerical answer

Consider the augmented grammar parsed with an SLR parser, terminals $\{a,b,c,d,\#,@\}$: $S'\to S$; $S\to SS\mid Aa\mid bAc\mid Bc\mid bBa$; $A\to d\#$; $B\to @$. Let $I_0=CLOSURE(\{S'\to\bullet S\})$. The number of items in the set $GOTO(I_0,S)$ is ___________

Practise this question in The GATE Grind →

Show answer and explanation

Correct answer: 10

Explanation

GOTO(I0,S) contains S'→S• and S→S•S, plus the closure of S: S→•SS, S→•Aa, S→•bAc, S→•Bc, S→•bBa, A→•d#, B→•@. That is 2 + 8 = 10 items.