Redirected from SLR parser
A grammar that can be parsed by an SLR parser but not by an LR(0) parser is the following:
Constructing the action and goto table as is done for LR(0) parsers would give the following item sets and tables:
The action and goto tables:
action | goto | ||
state | 1 | $ | E |
0 | s1 | 2 | |
1 | s2/r2 | r2 | 3 |
2 | acc | ||
3 | r1 | r1 |
As can be observed there is a shift-reduce conflict for state 1 and terminal '1'. However, the follow set of E is { $ } so the reduce actions r1 and r2 are only valid in the column for $. The result are the following conflict-less action and goto table:
action | goto | ||
state | 1 | $ | E |
0 | s1 | 2 | |
1 | s2 | r2 | 3 |
2 | acc | ||
3 | r1 |
Search Encyclopedia
|
Featured Article
|