Grammar
A → B ( A B )
| .
B → A *( B A )*
| .
LR(0) Table
$)**()(AB
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(AB ( A B )) r(AB ( A B )) r(AB ( A B )) r(AB ( A B )) r(AB ( A B ))    
11 r(BA *( B A )*) r(BA *( B A )*) r(BA *( B A )*) r(BA *( B A )*) r(BA *( B A )*)    

SLR(1) Table
$)**()(AB
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(AB ( A B )) r(AB ( A B )) r(AB ( A B )) r(AB ( A B )) r(AB ( A B ))    
11   r(BA *( B A )*) r(BA *( B A )*) r(BA *( B A )*) r(BA *( 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.


Return home to enter a new grammar.