[antlr-interest] how to define post rule code
Li Xu
xu at cs.uml.edu
Tue Jul 26 12:10:53 PDT 2005
Hi,
I am using the ANTLR Java. My question is how does one define the java code
to be executed after all the generated rule code. For example, I have code block
{...//foo } and rule:
bar {any java initialization code}: ...rule_body ...;
The generated code I need is like:
public void bar() {
...//the generated ANTLR parsing code
{the foo block should be here, after all generated code}
}
I have looked thru the manual, and one can add preamble code after the rule name
(as shown above); however, I don't see anything about postamble--ie, the code
one can attach to the very end --after all the generated parsing code.
So, my question is can this be done and how?
PS. I need this to manipulate the AST tree, so I can set returnAST to the
tree I created in Java. Rightnow, the last line of code is returnAST=some_ast and is
generated by antlr.
Thanks and greetings!
Li Xu
More information about the antlr-interest
mailing list