Project ForgeSign up free
Compiler Design
Lexical Analysis & Parsing
GATE 2019
Expert

Consider the augmented grammar: S'→S; S→⟨L⟩ | id; L→L,S | S. Let I0 = CLOSURE({[S'→•S]}). The number of items in the set GOTO(I0, ⟨) is:

5

Explanation

I0 = {[S'→•S], [S→•⟨L⟩], [S→•id]}. GOTO(I0,⟨) advances the dot past ⟨ in S→•⟨L⟩, giving [S→⟨•L⟩], then takes its closure: since the dot precedes nonterminal L, add L→•L,S and L→•S; since the latter has the dot before nonterminal S, add S→•⟨L⟩ and S→•id. Total items: {S→⟨•L⟩, L→•L,S, L→•S, S→•⟨L⟩, S→•id} = 5 items.

Source: GATE CS 2019 (Set-2) (2019)

This question is part of a 15-day revision cycle — sign in and Project Forge will bring it back the day before you'd forget it.

Start revising free