December 2009
Intermediate to advanced
380 pages
9h 2m
English
We’ve done a lot with ASTs in this book, and it’s nice to see them visually. Rather than build all the tree diagrams in this book by hand, for example, I used an AST walker to generate DOT scripts. The templates I used are similar to those from the previous section. Because they aren’t tied to the web link model, we can reuse them to build an AST visualizer in this section.
For simplicity, let’s assume our trees follow Pattern 9, Homogeneous AST. Given a tree like (VAR int x (+ 3 3)), we want to generate DOT that gives us a visualization like the tree on the top of the next page.

We need to generate ...
Read now
Unlock full access