|
we cannot determine how to represent if/then and while using abstract syntax treesFigure 7 in my lecture notes on syntax shows an abstract syntax tree with both a while loop and an if. The textbook shows an if on page 33. Regarding the relationship between abstract syntax and flowchart, try drawing a flowchart for a small piece of a program (that is, a subtree of the abstract syntax tree), and then for the whole program. The flowchart for the small piece should appear as a part of the flowchart for the larger piece. The interesting phenomenon is the way that the parts of the flowchart correspond to the subtrees of the abstract syntax tree. One aspect of that correspondence is that separate subtrees of the abstract syntax tree correspond to disjoint parts of the flowchart. Nested subtrees correspond to two parts of the flowchart, one of them completely containing the other. Different subtrees of the abstract syntax tree never correspond to parts of the flowchart that overlap, except when one completely contains the other. I don't know where to go from here without a more definite question. We can take up the question in class on Friday if you like. Mike O'D. |
to: