Grammar
A → | A ( B A ) | | | . |
B → | B *( A B )* | | | . | | |
LR(0) Table
| $ | )* | *( | ) | ( | A | B |
0 |
r(A → ε) |
r(A → ε) |
r(A → ε) |
r(A → ε) |
r(A → ε) |
s1 |
|
1 |
acc |
acc |
acc |
acc |
acc/s2 |
|
|
2 |
r(B → ε) |
r(B → ε) |
r(B → ε) |
r(B → ε) |
r(B → ε) |
|
s3 |
3 |
r(A → ε) |
r(A → ε) |
r(A → ε)/s5 |
r(A → ε) |
r(A → ε) |
s4 |
|
4 |
|
|
|
s7 |
s2 |
|
|
5 |
r(A → ε) |
r(A → ε) |
r(A → ε) |
r(A → ε) |
r(A → ε) |
s6 |
|
6 |
r(B → ε) |
r(B → ε) |
r(B → ε) |
r(B → ε) |
r(B → ε)/s2 |
|
s8 |
7 |
r(A → A ( B A )) |
r(A → A ( B A )) |
r(A → A ( B A )) |
r(A → A ( B A )) |
r(A → A ( B A )) |
|
|
8 |
|
s9 |
s5 |
|
|
|
|
9 |
r(B → B *( A B )*) |
r(B → B *( A B )*) |
r(B → B *( A B )*) |
r(B → B *( A B )*) |
r(B → B *( A B )*) |
|
|
SLR(1) Table
| $ | )* | *( | ) | ( | A | B |
0 |
r(A → ε) |
r(A → ε) |
r(A → ε) |
r(A → ε) |
r(A → ε) |
s1 |
|
1 |
acc |
|
|
|
s2 |
|
|
2 |
|
r(B → ε) |
r(B → ε) |
r(B → ε) |
r(B → ε) |
|
s3 |
3 |
r(A → ε) |
r(A → ε) |
r(A → ε)/s5 |
r(A → ε) |
r(A → ε) |
s4 |
|
4 |
|
|
|
s7 |
s2 |
|
|
5 |
r(A → ε) |
r(A → ε) |
r(A → ε) |
r(A → ε) |
r(A → ε) |
s6 |
|
6 |
|
r(B → ε) |
r(B → ε) |
r(B → ε) |
r(B → ε)/s2 |
|
s8 |
7 |
r(A → A ( B A )) |
r(A → A ( B A )) |
r(A → A ( B A )) |
r(A → A ( B A )) |
r(A → A ( B A )) |
|
|
8 |
|
s9 |
s5 |
|
|
|
|
9 |
|
r(B → B *( A B )*) |
r(B → B *( A B )*) |
r(B → B *( A B )*) |
r(B → B *( A B )*) |
|
|
The grammar is not LR(0) because:
- shift/reduce conflict in state 1.
- shift/reduce conflict in state 3.
- shift/reduce conflict in state 6.
Neither is it SLR(1) because:
- shift/reduce conflict in state 3.
- shift/reduce conflict in state 6.
|