Hi,
>
> I was wondering if any one has previously created a "pretty printer"
> adapter that traverses a standard Java AST and outputs the Java code.
> Is there any standard way in which this can be done with out having
> to write over-riding every production rule's method? I'm just trying
> to save myself from writing a heap of code here :)
>
Dumping the parse tree as string is quite simple. The nodes overwrite the toString()
method. So a simple dump can be achived wihtout problems by System.out.println(Start).
If you want to write a pretty printer you should overwrite the toString() method.
What I did is to let the visitor create a StringBuffer on creation which is filled
by the defaultCase() method or if needed by the production methods.
When everything is finished toString() simply returns the StringBuffer.
Cheers,
Thomas