Question

In the below example, it's clear that when you want to go in state 0 to state 3 through T, you will face a reduction and normal state in one state.
To be honest, I didn't see that before. That's why I am asking.

Is this possible? Shall I normally continue reducing? OR Am I wrong?

enter image description here

Here is the Grammar in case of needing it:

E ---> E+T | T
T ---> T*F | F
F ---> (E) | id

Was it helpful?

Solution

If you have no lookahead information, this is a shift/reduce conflict because the parser can't tell whether it should shift (follow the GOTO information) or reduce. This grammar, therefore, wouldn't be LR(0). If you have additional context about when to perform the reduction (perhaps if you're using an SLR(1), LALR(1), or LR(1) parser), then it's okay to have both a shift and a reduce in a state as long as the shift and the reduce aren't on the same terminal symbol.

Hope this helps!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top