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) m = 2 while (a < b) { a = 2; b = 1; }(Note the "dummy" node ";" which links together statements within the same block. Such things are unavoidable.) In parenthesized form, the second tree would be written as,
(while (< (a b)) (; (= (a 2)) (= (b 1))))
On this page are some further ideas for the form of AST nodes, and also what the output might look like. The point of the output is to get an accurate representation of the structure of the tree.
Back to CS 230 Home Page