I am using this standard question from Dragonbook as an example, (the first problem) . I have trouble with what happens in State 4 on LR(1) parsing. Once it is reduced by the rule C->d, now what will the current state be? It seems like it could be both State 0 or State 3 (since state 3 loops back on itself on the lookahead c), i.e the GOTO of C from either state 0 or state 3. I am confused on states like 3 that loop into themselves.
The grammar is this:
$$S' \rightarrow S $$ $$S \rightarrow CC $$ $$S \rightarrow cC $$ $$C \rightarrow d $$
Question 1 : When the machine is at state 3. On encountering d as a lookahead, what is the action, and the new state?
Question 2 : At a more fundamental level, what do you do following a reduce in any kind of LR parsing. You can't stay in that state itself, and have to go somewhere else right? How do you make that choice?
Edit: I made a small mistake in the grammar productions. I had originally included the grammar C -> c which was a mistake, and was removed.