Wednesday, August 14, 2002 04:31 PM
I've been working on a JavaEmitter that walks a Java AST, printing it out as Java code.
It's actually quite simple, but I'm having trouble getting rid of annoying little spacing
I'll share it once I've gotten it more robust.
I just hit a snag on this though, so here's a question for the ANTLR gurus:
There is no "STATEMENT" node in the Java AST because of the way the grammar's
defined - the rule for "statement" doesn't get its own node. One of the alternatives
for statment is an EXPRESSION followed by SEMI. I need to output a SEMI
when I see an EXPRESSION node in the AST, but ONLY when the EXPRESSION node's
parent is a "STATEMENT", but there is no "STATEMENT" parent.
I could just look for an "SLIST" parent, but it seems kinda kludgy. Especially
since there's no built-in getParent() method in AST or CommonAST.
Would I need to change java.g to get around this, or am I missing something?