0% found this document useful (0 votes)
26 views10 pages

Lecture 11

This document discusses SLR(1) parsing and how to construct an SLR(1) parsing table. It contains the following key points: 1. LR(0) parsing is too weak for practical use and SLR(1) parsing is presented as a more powerful alternative. 2. The steps to construct an SLR(1) parsing table are to create an augmented grammar and determine the parsing actions based on the follow sets of nonterminals. 3. There can be shift-reduce and reduce-reduce conflicts when constructing the parsing table that must be resolved.

Uploaded by

abdul rehman
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views10 pages

Lecture 11

This document discusses SLR(1) parsing and how to construct an SLR(1) parsing table. It contains the following key points: 1. LR(0) parsing is too weak for practical use and SLR(1) parsing is presented as a more powerful alternative. 2. The steps to construct an SLR(1) parsing table are to create an augmented grammar and determine the parsing actions based on the follow sets of nonterminals. 3. There can be shift-reduce and reduce-reduce conflicts when constructing the parsing table that must be resolved.

Uploaded by

abdul rehman
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 10

SLR PARSING

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 1: Create Augmented Grammar


 E’ -> E
 E->T+E
 E->T
 T->i
How to construct parsing table?...

• 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

1. E->T+E 1. Follow(E)-> {$}


2. E->T 2. Follow(T)->{+,$}
3. T->i
Conflicts
 Multiple entries ……….
 SR Conflict
 RR Conflict
SR Conflict
 S->Aa | bAc | dc | bda
 A -> d
 Step 1:
 S’ -> S
 S->Aa
 S-> bAc
 S-> dc
 S-> bda
 A -> d
SR conflict
If A->  α. a β
1 B-> γ .
0
S’ ->. S If follow(B) contains letter
S S’ -> S.
S->.Aa followed by . Symbol in A
S-> .bAc production, then its SR
S-> .dc A
conflict.
S-> .bda 2
A -> .d Here, follow(A) = {a,c}
S->A.a
b

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-> γ .

S’ -> .S If follow(A) Πfollow(B) ≠ φ


S->.Aa
S-> .Bc then its RR conflict.
S-> .bBa
B-> .d Here, follow(A) = {a}
A ->.d follow(B) = {c,a}

A->d.
B->d.

You might also like