Professional Documents
Culture Documents
Lecture 11
Lecture 11
LR(0) Isn’t Good Enough
LR(0) is the simplest technique in the LR
family.
Too weak to be of practical use for
a very limited set of grammars
Today we will consider SLR(1) where the S
stands for simple
How to construct SLR parsing
table?
E->T+E
E->T
T->i
• Step 2: 1
5
E’ -> .E Accepted
E->.T+E E -> T+E.
E E’ -> E .
E->.T
T->.i
T E
0 4
2 E -> T+.E
E->T.+E + E->.T+E
E->.T T
E->T.
T->.i
2
i i
3
T ->i. 3
Parsing Table
i + $ E T
0 S3 1 2
1 accepted
2 S4 r2
3
r3 r3
4 s3 5 2
5
r1
d
4 3
S-> b.Ac d A->d.
A -> .d S->bd.a
S-> d.c
S-> b.da
A -> d.
RR Conflict
S’ -> S
S->Aa
S-> Bc
S-> bBa
B-> d
A -> d
RR conflict
If A-> α.
0 B-> γ .
A->d.
B->d.