How to Obtain JTB
Authors / Feedback
Special Edition for GJ
How to get GJ to work with JDK > 1.2.1
The developers abandoned GJ at version 0.6m because it got the nod in JCP (as JSR0014)
to be included in some future version of the JDK, possibly 1.5. Chapman Flack has succeeded
in updating the GJ 0.6m retrofit classes to JDK 1.4. See
this page to learn how.
JTB 1.2.2 was released on May 15, 2000. See
the release notes for new features and
download it if you would like to try it.
JTB 1.2.2 was built and tested using JavaCC version 1.0.
|JTB GJ1.1.2 was released on May 15, 2000. It is a special
edition working with GJ, a design that extends the Java programming language
with generic types and methods. For further information or downloading
this special edition, please go to Special Edition
We are interested in your opinion of JTB! To find out
what you think of it, we have created a questionnaire
that we would really appreciate if you took the time to answer.
JTB is a syntax tree builder to be used with the Java
Compiler Compiler (JavaCC) parser generator. It takes a plain
JavaCC grammar file as input and automatically generates the following:
New visitors, which subclass DepthFirstVisitor or ObjectDepthFirst,
can then override the default methods and perform various operations on
and manipulate the generated syntax tree. For more information about
the Visitor design pattern, see the book Design
Patterns: Elements of Reusable Object-Oriented Software.
A set of syntax tree classes based on the productions in the grammar, utilizing
the Visitor design pattern.
Two interfaces: Visitor and ObjectVisitor. Two
depth-first visitors: DepthFirstVisitor and ObjectDepthFirst,
whose default methods simply visit the children of the current node.
A JavaCC grammar with the proper annotations to build the syntax tree during
How to Obtain JTB
Both compiled executables and source code for the newest version of JTB
are available. You can download them here.
Also available are some examples of its use.
JTB requires a Java 1.1 or higher virtual machine. In addition, it
is compatible with JavaCC 0.6.x, or higher.
After downloading and installing JTB, using it is a matter of running it
on your .jj JavaCC grammar file with the command
% jtb yourgrammar.jj
This will generate
See the documentation for more information about
The subdirectory syntaxtree containing a class for each production
in the grammar.
The subdirectory visitor: Visitor.java, the visitor interface;
ObjectVisitor.java, the visitor interface with return value and
argument; DepthFirstVisitor.java, the default implementation of
the Visitor interface; ObjectDepthFirst.java, the default
implementation of the ObjectVisitor interface.
The file jtb.out.jj, the original grammar file now with syntax
tree building code inserted.
To generate your parser, simply run JavaCC on jtb.out.jj with
% javacc jtb.out.jj
Once you are familiar with the specifics of the tree JTB generates (see
the documentation for details) as well as programming
using the Visitor design pattern, writing your own visitors is a cinch.
Simply subclass DepthFirstVisitor or ObjectDepthFirst,
overriding the methods you need to.
You can compile all the generated classes by executing javac
on your class containing the main() method.
Authors / Feedback
JTB was designed at Purdue University, West Lafayette, Indiana, USA:
||May, 1999 to
|Current JTB and web page developer. Continue Kevin's work and
upgraded JTB to v1.2.
|All versions of JTB, up to and including v1.1.2, were programmed by
Kevin Tao, and he also developed the JTB web page.
Dr. Jens Palsberg
|Responsible for the original idea, important concepts, and project
supervision and guidance.
If you have any questions, comments, or problems regarding JTB, we
would be glad to hear them. Please send trouble reports and questions
to Wanjun Wang, and comments to
Wanjun Wang or Jens
Thanks go to Markus Kuhn
and Nate Nystrom
for providing testing and comments, to Gerald
Baumgartner for helpful advice, and to Michal
Young for financial support.
We would also like to thank the following people for their helpful suggestions
(in alphabetical order): Dennis Brylow, Bruno Daniel, Dave
Dyer, Chapman Flack, James Lee and Tom Tourwe. We would also
like to thank the numerous people who have given us their feedback and
suggestions for improving JTB. Without them, our seemingly endless
"to do" list would be quite a bit smaller. : )
If I've forgotten any names, please let
Work on JTB is graciously supported by DARPA through a subcontract
with Northeastern University.
JIE: The Java Instrumentation
Engine (JIE) is a generic Java source code processor which inserts
instrumentation code at specified locations in a given sourcecode.
"The project makes intensive use of JTB and the visitor pattern (over 20
visitor classes) to perform transformation of Java source code. I
found JTB effective and flexible, and its pattern-based approach has been
a crucial element in the success of the project." -- Eran Tromer
JDE: The Java Development
Environment (JDE) is an Emacs Lisp package that interfaces Emacs to
command-line Java development tools (for example, JavaSoft's JDK).
JDE features include: JDE menu with compile, run, debug, build, browse,
project, and help commands; syntax coloring; auto indentation; compile
error to source links; source-level debugging; source code browsing; make
file support; automatic code generation; Java source interpreter (Pat Neimeyer's
BeanShell). "I find the JTB extremely useful. What I like about
the JTB is that it provides the JDE with a single parser that can be adapted
to multiple purposes, including unforeseen applications." -- Paul Kinnucan