GATE 2021 CS (CS2) – Question 61
The augmented grammar is S′→S; S→S#cS | SS | S@ | <S> | a | b | c, with #,@,<,>,a,b,c terminals. Let I0=CLOSURE({S′→·S}). Find the number of LR(0) items in GOTO(GOTO(I0,<),<).
Practise this question in The GATE Grind →
Show answer and explanation
Correct answer: 8 to 8
Explanation
After shifting the first <, the kernel contains S→<·S>. Closure adds all seven productions of S with a dot at the start: the three starting with S, the bracket production, and the three single-terminal productions. Shifting another < regenerates the same kernel and closure. Thus there are one plus seven = eight items.