Question:medium

Consider the following augmented grammar with terminals {#, @, <, >, a, b, c}.

$S' → S$
$S → S\#cS$
$S → SS$
$S → S@$
$S → <S>$
$S → a$
$S → b$
$S → c$

Let I0 = CLOSURE({ S' → • S }). The number of items in the set GOTO(GOTO(I0, <), <) is  .

Show Hint

In LR parsing, always apply CLOSURE after each GOTO to count all reachable items.
Updated On: Feb 2, 2026
Show Solution

Correct Answer: 8

Solution and Explanation

To solve the problem, we need to determine the number of items in the set GOTO(GOTO(I0, <), <) given the augmented grammar.

First, define I0 as CLOSURE({ S' → • S }). The closure of I0 includes the initial item and any items that can be derived from the grammar where the non-terminal is on the right after a dot (•).

Step 1: Compute CLOSURE(I0
1. Start with:

S' → • S2. Since S is to the right of the dot, include productions for S from the grammar:S → • S\#cS
S → • SS
S → • S@
S → • <S>
S → • a
S → • b
S → • cThis defines I0.

 

Step 2: Compute GOTO(I0, <)
Apply the GOTO function with symbol < on I0:
1. Find items where < is right after the dot:

S → • <S>2. Move the dot past <:S → < • S>3. Calculate closure for items with new dot position, adding items where S is to the right of the dot:S → • S\#cS
S → • SS
S → • S@
S → • <S>
S → • a
S → • b
S → • cDenote this set as IA.

 

Step 3: Compute GOTO(IA, <)
Apply the GOTO function with symbol < on IA:
1. Find items where < is right after the dot (none exist, since dot does not precede < in IA).

Step 4: Conclusion
No new items are added to GOTO(GOTO(I0, <), <) set since IA has no valid < transitions. Hence, the number of items ultimately settles only on the items derived:

  • S → < • S>
  • S → • S\#cS
  • S → • SS
  • S → • S@
  • S → • <S>
  • S → • a
  • S → • b
  • S → • c

Thus, there are 8 items.

 

This count confirms that the solution's value 8 fits the given range [8,8].

Was this answer helpful?
0