Professional Documents
Culture Documents
S dA
S aB
A bA
Ac
B bB
bc
S’ S
S dA | aB
A bA | c
B bB | c
1. LL(1) :
FIRST(S) = {d, a}
FOLLOW(S) = {$}
FIRST(A) = {b, c}
FOLLOW(A) = {$}
FIRST(B) = {b, c}
FOLLOW(B) = {$}
Parse Table:
X a b c d $
S S aB S dA
A A bA Ac
B B bB Bc
Proof:
A grammar is LL(1) if and only if it has two distinct productions such as A a | b and:
Hence LL(1).
2. LR(0) :
Proof:
After drawing a canonical collection of LR(0) items, we can go to final items, such as I1 , I9 ,
I4 , I6 , I7 , I10 , I11 to check for SR or RR conflicts.
In all these states, there is only one final item, which means there is no RR shift move which
means no SR conflict.
Hence LR(0).
3. SLR(1) :
If a grammar is LR(0) having no SR and RR conflicts, then the grammar will also be SLR(1).
Any LR(0) grammar can also be parsed by an SLR(1) parser.
Hence SLR(1).