Debugging and testing your syntax tree
The trees that you build must be rock solid. What this spectacular mixed metaphor means is: if your syntax tree structure is not built correctly, you can't expect to be able to build the rest of your programming language. The most direct way of testing that the tree has been constructed correctly is to walk back through it and look at the tree that you have built. This section contains two examples of doing that. You will print your tree first in a human-readable (more or less) ASCII text format, then you will learn how to print it out in a format that is easily rendered graphically using the popular open source Graphviz package, commonly accessed through PlantUML or the classic command-line tool called dot
. First, consider some of the most common causes of problems in syntax trees.
Avoiding common syntax tree bugs
The most common problems with syntax trees result in program crashes when you print the tree out. Each tree node may hold...