Short Evaluation Using AST: Implementation
51/69
• Every AST node, X,  has assigned two attributes X.t, X.f
Elementary ASTs:
A
or
B
A.t := or.t
A.f := L
B.t := or.t
B.f := or.f
or.t
or.f
L:
A
and
B
A.t := L
A.f := and.f
B.t := and.t
B.f := and.f
and.t
and.f
L:
not
A
A.t := not.f
A.f := not.t
not.t
not.f
1)
2)
3)
• Note: L = a new label
• Initialization: Let R is the root of AST, then:
R.t := True, R.f  := False (True & False are labels)
• Propagation: Attributes are propagated from root to leaves
in AST using rules 1), 2) and 3).
• Note: L = a new label