Example:
+ / \ a bis an AST node for a + b. In parenthesized form, this could be written:
( + ( a b ) )
Examples:
if while / \ / \ > := < ; / \ / \ / \ / \ a b m 2 a b := := / \ / \ a 2 b 1 AST for: AST for: if a < b then m := 2 while a < b do begin a := 2; b := 1 end(Note the "dummy" node ";" which links statements in the same begin..end block together. Such things are unavoidable.) In parenthesized form, the second tree would be written as,
(while (< (a b)) (; (:= (a 2)) (:= (b 1))))
Back to CS 230 Home Page