S := L '=' R | R L := '*' R | 'id' R := L
This is a grammar from the Dragon book, it resembles the C pointer dereferencing and assignment syntax. It shows well that it is not a SLR(1) grammar but a LALR(1) grammar.
| 1 | S := L '=' R |
|---|---|
| 2 | S := R |
| 3 | L := '*' R |
| 4 | L := 'id' |
| 5 | R := L |
| State | ACTIONS | GOTO | |||||
|---|---|---|---|---|---|---|---|
| id | = | * | $ | L | R | S | |
| 0 | s4 | s1 | 5 | 2 | 3 | ||
| 1 | s4 | s1 | 7 | 6 | |||
| 2 | r2 | ||||||
| 3 | A | ||||||
| 4 | r4 | r4 | |||||
| 5 | s8 | r5 | |||||
| r5 | |||||||
| 6 | r3 | r3 | |||||
| 7 | r5 | r5 | |||||
| 8 | s4 | s1 | 7 | 9 | |||
| 9 | r1 | ||||||
| 1 | S := L '=' R |
|---|---|
| 2 | S := R |
| 3 | L := '*' R |
| 4 | L := 'id' |
| 5 | R := L |
| State | ACTIONS | GOTO | |||||
|---|---|---|---|---|---|---|---|
| id | = | * | $ | L | R | S | |
| 0 | s4 | s1 | 5 | 2 | 3 | ||
| 1 | s4 | s1 | 7 | 6 | |||
| 2 | r2 | ||||||
| 3 | A | ||||||
| 4 | r4 | r4 | |||||
| 5 | s8 | r5 | |||||
| 6 | r3 | r3 | |||||
| 7 | r5 | r5 | |||||
| 8 | s4 | s1 | 7 | 9 | |||
| 9 | r1 | ||||||