JTB Home

What's New

Release Notes



JTB Base Examples:

  • JJTree/JTB
  • Pretty Printer
  • JTB

  • ObjectVisitor:
  • Expression Translator

  • Tutorial

    Why Visitors?

    Other Tools

    User Comments

    Special Edition for GJ

  • JavaCC
  • Design Patterns
  • Javasoft
  • GJ

  • Jump to Java!

    Here you will find some examples and links to programs built using JTB.  To download .jar files, you may need to click right-button on the file name and choose "Save Link As".  Some old examples and user-created programs for old versions of JTB may be obtained here

    JTB Base Examples

    These are examples provided by the author of JTB, Kevin Tao.  Contact current JTB developer Wanjun Wang at wanjun@purdue.edu for questions, comments, etc. 
    • JJTree/JTB comparison.  JJTree 1.0 (packaged with JavaCC 1.0) and JTB 1.2 were both used on a very simple grammar subset of Scheme to perform the task of finding and reporting undeclared variables.  Download this example and examine the differences between programming for JJTree and JTB.  Also see the Other Tools page for a discussion on the differences between these two tools. This example has been updated for use with JTB 1.2, JavaCC 1.0, and JJTree 1.0.
    • Pretty printer for the Java 1.1 grammar.  This example uses the Java1.1.jj grammar file included with JavaCC 0.7.1 in its original form.  It takes as input a Java file and outputs a nicely indented version.  The comments in the input file are preserved.  This example shows you how simple and organized the visitor pattern makes this task.  It uses the TreeFormatter template of JTB 1.2 (see the Documentation for details).  The example is now distributed in jar format.  See the Sun's Java documentation for information on using the jar utility.
    • Java Tree Builder.  As a slightly more complex example of using JTB, the current version of JTB itself was bootstrapped using a previous version of itself.  Download the package and see the source code.

    ObjectVisitor Examples

    • Expression Translator.  This example transforms an infix expression to a prefix expression.  It uses the Calc1.jj grammar provided with the JavaCC distribution, 

    • version 1.0.  Some changes were made to the original grammar file to fit in with JTB 1.2.  This example shows you how to use ObjectVisitor and ObjectDepthFirst.  For more information, please read the README file included in the example package.  You may also compare this example with the Advanced Example on the JTB GJ page, and you will find how GJ can reduce type castings.

    Maintained by Wanjun Wang, wanjun@purdue.edu.
    Created September 4, 1997.
    Last modified Aug. 8, 1999.