compiler construction - Why does a LR(1) DFA doesn't have a Shift/Reduce conflict? -


given grammar: enter image description here

for lr(0) dfa can see why shift/reduce conflict:

enter image description here

(partial dfa)

but can't understand why lr(1) dfa solves problem?

enter image description here (partial dfa)

for me still shift reduce conflict since lookahead symbol same b rule? how should lr(1) parser distinguish them, not lr(0) one?

because can reduce b→ε if lookahead a.

in lr(0) cannot take lookahead account, in lr(1) can decide based on next input symbol, , here rule simple: if next symbol b, shift it, , if a, epsilon reduction of b.


Comments