Professional Documents
Culture Documents
Unit 3 Part-5
LL(1), LR(0). SLR(1)
CSE
By Himanshu Swarnkar
Engineering College Banswara
Parser
Brute force
Method Recursive Descent Non Recursive LR(0) SLR(1) LNR(1) CLR(1)
Descent(LL(1))
SR and RR Conflict in LR(0) Parser
a A→γ.
A→γ. b c
B→β. a
I5 I6 SR Conflict 5 r1/S6 r1 r1
RR Conflict 6 r1/r2 r1/r2 r1/r2
I2 S3 S4 I5
States
I3 S3 S4 I6
I4 r3 r3 r3
I5 r1
I6 r2 r2 r2
In order to check if a grammar is LL(1) , You must make sure that
1.) The grammar is not an ambiguous grammar
2.)The grammar should not be left recursive
3.)The grammar should be deterministic.
4.)Basically the idea is that if you construct the LL(1) parsing table , no cell should have more than one entry
In order to check if a grammar is LR(0) , You must make sure that
1.) Check SR and RR Conflict. If not than the grammar is LR(0).
a b + * $
Follow(E)={+,$}
I2 s4 s2 r2 r2
Follow(T)={+,$,a,b}
r
I3 r4 r4 r4 S8 4
I7 r3 r3 r3 S8 r3
I9 S4 S5 r1 r1
LL(1) X
Example: 3 Example: 4
LR(0) X
LL(1) X SLR(1)
LR(0)
SLR(1)