WebGain provides a tool, called JJTree, which allows to use grammars to define the class structure. JJTree now also provides support for the Visitor design pattern.

Java Compiler Compiler Home page

Demeter/Java goes beyond JJTree (while at the same time using the Java Compiler Compiler very successfully; JavaCC is a great tool):
1. we generate a larger visitor library, like a CopyVisitor, DisplayVisitor, EqualVisitor, PrintVisitor etc.
2. we define traversals succinctly, using strategies. (ftp://ftp.ccs.neu.edu/pub/people/lieber/strategies.ps)
3. our visitors are more refined: before/after/around methods on edges and nodes, return and init methods, etc.

One summary of the Visitor Design Pattern is:

The Visitor pattern lets us define a new operation on an object structure without changing the classes of the objects on which it operates.

But that is also the summary for a propagation pattern which we used already in the early 1990's.

A propagation pattern lets us define a new operation on an object structure without changing the classes of the objects on which it operates.

The visitor pattern proposes an implementation in terms of visitor objects. Propagation patterns were implemented differently by inlining the visitor object code. But the interface is the same. Our first propagation pattern publication was in July 1992 and then in September 1992.

For an interesting related academic tool, see Java Tree Builder Home Page at Purdue University.