Consider the augmented grammar given below: S' → S S → 〈L〉 | id L → L,S | S…
2019
Consider the augmented grammar given below:
S' → S
S → 〈L〉 | id
L → L,S | S
Let I0 = CLOSURE ({[S' → •S]}). The number of items in the set GOTO (I0 , 〈 ) is: ________.
Attempted by 104 students.
Show answer & explanation
Correct answer: 5
Answer: 5 items.
Compute I0 = CLOSURE({S' → •S}). I0 contains:
S' → •S
S → •〈L〉
S → •id
Compute GOTO(I0, 〈):
Shift the dot in S → •〈L〉 over '〈' to get S → 〈•L〉.
Take the closure: the dot is before nonterminal L, so add productions for L with the dot at the start.
This adds L → •L,S and L → •S. Because L → •S has the dot before S, add S → •〈L〉 and S → •id. No further new items appear.
The final set GOTO(I0, 〈) contains these five items:
S → 〈•L〉
L → •L,S
L → •S
S → •〈L〉
S → •id
Therefore the number of items in GOTO(I0, 〈) is 5.
A video solution is available for this question — log in and enroll to watch it.