JavaEmitter

JavaEmitter prints Java code from an ANTLR AST.

The JavaEmitter.java class generates reasonably formatted Java code from an ANTLR AST. The IndentingPrintStream.java helper class is also needed. The JavaEmitter API page explains what it does and a little about how it works (see the print() method).

The JavaEmitter main() method is an example of how to use it in your program. Just download these the two source files above and place them in your antlr-2.7.2/examples/java/java directory. Include this directory (and the antlr.jar file) in your CLASSPATH, compile with:


java antlr.Tool java.g
java antlr.Tool java.tree.g
javac *.java

and then run it with:

java JavaEmitter YourJavaFile.java

Change History:
7/17/03: Fixed problem with "new String [] {...}" reported by Paul Taney
7/16/03: Fixed to work with out-of-the-box ANTLR.
6/29/03: Initial version.

Report questions/problems to: atripp-at-comcast-dot-net
Andy Tripp 7/16/03