Tree-Walking for Peeps

Tree-Walking with Nuthatch

Nuthatch is a system of traversing, collecting information from, and rewriting trees, based on the idea of tree walking. The main application is software analysis and transformation. We provide a library, Nuthatch/J, for doing tree walking in Java, with adapters for interfacing with popular software transformation tools like Stratego/XT and Rascal.

Transformations are described as walks that proceed in programmer-defined steps. Each step may which may observe join points of a traversal, and affect state associated with the walk and also rewrite the walked tree. Each step ends by walking to a different node in the tree, following the tree branches.

Nuthatch is described in the upcoming paper Walk Your Tree Any Way You Want.

Example: ToString

This simple example shows how to a walk a tree and convert it to a term representation (such as +(5, *(+(7, 3), 4)), for example).