You are on page 1of 1

Home About Privacy Contact Us

HOME LECTURE NOTES SYLLABUS QUESTION PAPERS MCQ

Construction of SLR Parsing Table


POPULAR POSTS
Estudies4you

Construction of SLR Parsing Table Block Block Structure and Non-


Structure Block Structure Storage
The parsing table has two elds associated with each state in the DFA known as action
and Non- Allocation
and goto. These are computed using the following algorithms: Block September 04, 2017
Construct C ={I0,I1,…..In}, the collection of sets of LR(0) items for G’
State i is constructed from Ii. The parsing actions for state i are determined as follows: Access Access to Nonlocal Names
              If [A→α.aβ] is in Ii and goto(Ii, a) = Ij, then set action[i, a] to “shift j.” Here, a is to Nonlocal September 05, 2017
required to be a terminal Names

               If [A→α.] is in Ii then set action [i, a][ to “reduce A→ α] for all a in FOLLOW(A), here A
may not be S’ Differen Difference between Machine
               If [S’ → S.] is in Ii, then set action[i, $] to “accept” ce Dependent and Independent
between Code Optimization
If any con icting actions are generated by the above rules, we say the grammar is not
Machine November 20, 2017
SLR(1). The algorithm fails to produce a parser in this case.
The goto transitions for state I are constructed for all non-terminals A using the rule: if
goto(Ii, A) = Ij, then goto[i, A] =j TECHNOLOGY
All entries not de ned by rules (2) and (3) are made “error”
The initial state of the parser is the one constructed from the set containing item [S’ → S] 3/Web Technologies/post-list
Number of productions in the grammar from onwards and use the production number
while making a reduction entry
CATEGORIES
For example for the given grammar
              1. E → E + T Arithmetic 7
               2. E → T
Compiler Design 74
               3. T → T * F
               4. T → F COMPUTER PROGRAMMING IN C 49
               5. F → ( E )
OOAD MCQ 9
               6. F → id
OOAD Notes 63
This construction requires FOLLOW of each non-terminal present in the grammar to be computed
Web Technologies 71
The grammar that has a SLR parsing table is known as SLR(1) grammar. Generally, 1 is omitted

The canonical collection of SLR(0) items are


I0:
E’ → .E
E → .E + T
E → .T
T → .T * F
T → .F
F → .( E )
F → .id

I1:
E’ → E.
E → E.+ T

I2:
E → T.
T → T .* F

I3:
T → F.

I4:
F → (.E)
E→.E+T
E → .T
T → .T * F
T → .F
F → .( E )
F → .id

I5:
F → id.

I6:
E → E + .T
T → .T * F
T → .F
F → .( E )
F → .id

I7:
T → T * .F
F → .( E)
F → .id

I8:
F → ( E .)
E → E. + T

I9:
E → E + T.
T → T. * F

I10:
T → T * F.

I11:
F → ( E ).

The DFA for the canonical set of SLR items is


Construction of SLR Parsing Table,canonical collection of SLR(0) items,how to construct
slr parsing table, how to construct lr(0) parsing table, r16 jntuh compiler design notes, r16
jntuh compiler design lecture notes,jntuh r16 3-1 compiler design notes pdf,estudies4you

Construction of SLR Parsing Table for Example


STATE ACTION GOTO
id + * ( ) $ E T F
0 s5 1 2 3
1 s6 s4 ACC
2 r2 s7 r2 r2
3 r4 r4 r4 r4
4 s5 S4 8 2 3
5 r6 r6 r6 r6
6 s5 s4 9 3
7 s5 s4 10
8 s6 s11
9 r1 s7 r1 r1
10 r3 r3 r3 r3
11 r5 r5 r5 r5
Here , si means shift state i. ri means ‘reduce by using production number I’ and ACC
means Accept, blank means error.

Canonical Construction of Home LR Parser


LR(0) Items

COMPILER DESIGN

YOU MAY LIKE THESE POSTS

NEWER OLDER

Contact Info Contact Form


This blog is only for promotional purpose. If you Have any Name Email *
problems with these posts send mail to
indianonlineviews@gmail.com also send suggestions and
queries. Message *

SEND

Created By SoraTemplates | Estudies4you Blogger Templates

You might also like