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