SLR Parser Actions
SLR (simple LR) is like LR(0) but reduces on (X::=p.) only if additionally:
- t follow(X) where is current token
Otherwise, same as LR(0) Parser Actions
Let K be parser state at the end of stack and t current token:
- if there is a transition for non-empty
- shift: push t onto stack
- if t is EOF, then accept
- reduce: if item K and t follow(X) then
- pop p from stack
- push X onto stack
- if none possible, report syntax error
- if both possible, shift-reduce conflict: grammar not SLR
Note: SLR (unlike LR(1)) uses lookahead in a simple way, but it is useful