0% found this document useful (0 votes)
10 views

Compiler Assignment

Solution for uploaded compiler design assignment

Uploaded by

sahilb0602
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Compiler Assignment

Solution for uploaded compiler design assignment

Uploaded by

sahilb0602
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Q) uen qramnnasj

F (E) id

AJanented qrarmooar witl be;


SE

. (E)

GOTO (3o,E) =1

closure ot S . E S’E
S.E

E’T.
E’T *F

f’.(E)
F’.d
T F.

F’(.E)
Cnous getting the elou ot t)

F.(E)

GoTO (3o, td) T6

GOTO (11,+) = 3e
EEt.T

FCE)
c.(E)
Go70 (4 td) =Is

T T* f.
F(E)
6E.+T

F’ (t)'
GOTO(IyF
&OTO (Ig,t) =1G
GoTo (T4 ()= I4
(I,td) = Ig
Is GUTO (Ti)Ig
GoTO

Iq Can't qo anywhere from


eoTo (Ie, T) statts T0 8I
EE+T.

the abwe aremar


GOTO (T,F) I
the
pasing
LR tems

(J, id)= IS
G0TO
farsing Tabte
Anpt
states Aetion Tterrh
"Tterns
T

2 2

4
y4

8 2 3
S5
r6

64

SS

8 S6

(1
02) Gtven Seman bt nudeo
-E-val = ? haeto fnd

Eyal - Tvad
Tual = T*val + F.val

T’f T.val = Feva


digttAval
F afgt Fval =

pTCedenee than 8, ths


the rules. # has niqner
Tren
can
7#6 4#A 24t| 8 2
the ezprssjon; 4S 40

be simplifeo to;
T.val t F.val
Using T-T#f Tval
oeratr that euate
find the appnpt iatk
naw We hae to
erpeyjn to 20. int dh
Gval =Ewal Toval.
ypothess:E’E8T

45 | 13lll2
hypute
bavat EAT

22

aloe xPUon is evawated -to 20,


shge
the mising semanbieeis

for the expresiÝn

we

GS -4+ t -s
+6-3t-4
. # has pre c£den ce

) 24
Q3)
calcuiabon of the loop inuarant
Dremeving the
ubside the nlle
lop to eplace
loop
Ttdundant Cal Culatduy

i)Sen gth reduc hian:


the ioperahon (iAB) bysi+ ix i (a)
Tepla cng the
ieplacingte 9°sy operabony oy the
mulbplidabue alttma °es (b)
iRt) Atenatively can uye prrcomputed uadeo of y y if
y wil aluay oe the sume
Opbmised code?
2=5

p1

forli- 13 isn jitt)¬


Q4) Gien;
cN.

the abNe enerssibn can be caleulated os

i-1
wntle i<nn theo
t1=i
t2 = ii
i
b2 = t2*
S = S+t1
S= S+ t2

The epreented using


lbop caun be repreSeNted
?f qoto
stotemerto, thus the three address code loeco meo

2) = 1

B) tf (i >n)
g0 to 11

i
t2 = i
s) t 2
6) t2*

S =S+ t1
+)
8) S S+t2
goto
1
t
S
t2
t2
tii
116
Operato
Temporony Operand
L
and2 oer
epresentation Quadrvples
condition oeoUt 11)
3 to
i+1 i= 4)
q)

You might also like