Similar questions 4 more →
Parsing & Syntax Analysis

Answer & solution
Official answer: 5
Step through it (3 steps)
1. An LR(0) item is a production with a dot marking how much has been recognized. Closure adds productions of any nonterminal immediately after a dot, with their dots at the start.
2. I0 contains S′→·S, S→·(L), and S→·id. Only S→·(L) has an opening parenthesis immediately after its dot.
3. GOTO on '(' advances that dot, yielding the kernel item S→(·L). Its dot precedes L, so add L→·L,S and L→·S.
4. The first of these new items again has L after its dot, but adding L's productions repeats existing items. The second has S after its dot, so add S→·(L) and S→·id.
5. The last two dots precede terminals, so closure stops. The complete set is {S→(·L), L→·L,S, L→·S, S→·(L), S→·id}: exactly 5 items.
6. Do not carry S′→·S into this destination merely because it was in I0. GOTO keeps shifted matching items and then their closure, not the entire starting state.