Академический Документы
Профессиональный Документы
Культура Документы
production semantic rules Parse tree for real id1, id2, id3
D
D => T L L.in := T.type
T => integer T.type := integer T.type = real L.in = real
T => real T.type := real
L => L1, id L1.in := L.in
real L.in = real , id3
addT(id.entry, L.in)
L => id addT(id.entry, L.in)
L.in = real , id2
id1
a+a*(b-c)+(b-c)* d
note the common sub-expressions a and (b-c)
+
+ *
*
-
d
a b c
see ASU Fig 5.12 (p291) for the instructions (mknode / mkleaf) and Fig 5.13
(p292) for an array implementation of the nodes
T.val = 9 R.i = 9
num.val = 2 ¤