Short Evaluation Using AST: Example
52/69
Example:
a or (b and (not c)):
or
and
not
a
c
b
X:
Y:
AST:
or.t := T
or.f := F
a.t := or.t
a.f := X
(= T)
b.t := Y
b.f := and.f
(= F)
c.t := not.f
c.f := not.t
(= F)
Note:
• T = True
• F = False
(= T)
and.t := or.t
and.f := or.f
(= T)
(= F)
not.t := and.t
not.f := and.f
(= T)
(= F)
T: …
F: …
X:
if b goto Y
goto F
if a goto T
goto X
Y:
if c goto F
goto T