You are on page 1of 21

i

3y Pacrouog
ckorack .

7Rocnoues common u
halps ankstokontn ke
(b) 8pkea
.
FiAST Foustd
A CB/cbee9,ab, cop3
da BC
4,,9,3
h4
d)
anthseo atrobu aks valua
tom old, noda.ond alus ot noda
alu
lohe kd aderbuk, b
Paein'nods Sblngs noda ond ndda

e) -1

add ()

M)-4 '
tt

t/ 4f
t
S
Mockn daperdsah toda ophaah

maekne Codla
maok.
that paRoro

fernade etnemadate
ma
Codei
oeg mplangheo (EaqLireo.

y '

R z i s2 e
Taa Gco n ma

X ns/12

-elY/
2..2 /e
0/s2/
*
T

A A A
ABab ABaBb AlBa-B
Cb Ca
C bCa
A BoB.bD
.Caf
e eBb»

cbCa
*

T **
7
A
S'>.8,h|Sd8,#),
a el, a,Sa- Ad,4A S aA.d. --aAd4
A C,d
S bed,
S ae a.Be, 4 eA G, d
, e
S aB.e, 4 2aBe,}
d e
Bd. 1 be-d, a,]e bed,
e
b .d
Ae,f , d1
A C, e T
bA.e. 4 Sb
A C
S8, -a, £),
Sa a el,
Ael, Sa-Ad,
A C, d
4A$ aA-4 SGAc4
SbBd,. a.Be, 4 A A G, al
aBe,
S.bAe S ae,
S a8.e,
d ,e
B. be-d, d [g-bed,
B d,d
S b . Ae,f |dB d-, d
A C, e
bA.e,¢
A C.,
| . | |
n n the above Cocde Tepre8ea a

taple, Consisthng of an 0Peralhen(cg


Gnd up h tiree
Perands (e a c
es
(,,6,C)
(i frue, 5 if false)

)
ach ine h e aioe Code represets a tripe
CmAi Gan operatin (e 2 t , Z -
)and up b thrce OPerand4
13)
3

D
258 ilee

7)a Wte the tiree- address Code tr H


l n g Code L4
Jr (St=1 Slep4Size Siept+)
ketz aray CSfet7
J SteP-1
lekey2arey Ci14413
1=o)
arrayLutJ1 Qral

a 1Key

e Sfel Size Jofe 14


QraySicy 7

Key aroyj) ot
G

2
Here are the semantic rules for the given
associated with synthesized and inheritedgrammar with the symbols T and L
attributes, respectively:
For the production D-> TL:
Compute the attribute T(D) as T(L).
For the production T -> int:

Compute the attribute T(T) as int.


Forthe production T-> real:
Compute the attribute T(T) as real.
For the productionL->L1 id:
Propagate the attribute L(L1) to L(id) if L(id) is inherited.
Compute the attribute T(L) as I(Id).
For the production L-> id:
Compute the attribute T(L) as T(id).
Note that we need to know whether the
attribute "in" of L(id) is inherited
synthesized to determine whether to
propagate the attribute
or
L{L1) to L(id).
Attribute dependency graph for the
The attribute statement "int a":
dependency graph shows that the attribute T(D)
attribute T(L) and the attribute
T(L) depends the
depends on the
is not inherited, so there is no need
on attribute T(id). The attribute L(id)
to propagate the attribute
the attribute T(id) is
computed as int based on the
L(L1) to L(id). Finally,
->int. Therefore, the type of the statement semantic rule for the production T
"int a" is int.

The attribute dependency graph shows that the attribute T(D) depends on the
attribute T(L) and the attribute T(L)
depends the attribute
on
is not inherited, so there is no need to propagate the attributeT(id). The attribute L(id)
the attribute T(id) is L(L1) L(id). Finally,
to
->int. Therefore, the
computed as int based on the semantic
rule for the production T
type of the statement "int a" is int.

:T
J-1
I i 13.: Jt1
RarrayLI3]- ke
3 Skep+1

8b) Consider the code Sejuence


X2

2-1
4(74)

5
il ee 2ddressCde
tojn he jiorl7rat h by Cmsideri
Plyn al
EI47a teckges
Oubilee Soil tas
(M 20

)1
X<0

4 X-1

Hfalse
3
Í3
. ok2

) ww

13 X>4
.

You might also like