Example for LALR(1) Parser-2
STEP 3: Parsing table
| STACK | ACTION | GOTO |
| a | b | $ | S | A | |
| 0 | S36 | S47 | 1 | 2 | |
| 1 | Accept | ||||
| 2 | S36 | S47 | 5 | ||
| 36 | S36 | S47 | 89 | ||
| 47 | r36 | r36 | r36 | ||
| 5 | r1 | ||||
| 36 | S36 | S47 | 89 | ||
| 47 | r36 | ||||
| 89 | r2 | r2 | r2 | ||
| 89 | r2 |
Here, since 36, 47, and 89 are duplicates in the table they will not be considered.
Therefore, This is the reduced LALR Parser table
For the given input string, W=”aabb” using the LALR(1) parsing table.
| STACK | I/P BUFFER | ACTION TABLE | GOTO TABLE | PARSING ACTION |
| $0 | aabb$ | [0,a]=S36 | Shift | |
| $0a36 | abb$ | [36,a]=S36 | Shift | |
| $0a36a36 | bb$ | [36,b]=S47 | Shift | |
| $0a36a36(b47) | b$ | [47,b]=r36 | [36,A]=8 | Reduce A → b |
| $0a36(a36A89) | b$ | [89,b]=r2 | [36,A]=8 | Reduce A → aA |
| $0(a36A89) | b$ | [89,b]=r2 | [0,A]=2 | Reduce A → aA |
| $0A2 | b$ | [2,b]=s47 | Shift | |
| $0A2b47 | $ | [47,$]=r36 | [2,A]=5 | Reduce A → b |
| $0A2A5 | $ | [5,$]=r1 | [0,5]=1 | Reduce S → AA |
| $0S1 | $ | [1,$]=accept |
Reference Link
