[antlr-interest] Calling templates in actions

Carl Crowder carl.crowder at gmail.com
Sat Mar 15 09:26:20 PDT 2008


Hello,

I'm writing a grammar for a scripting language which gets translated 
into Java. Basically I want to add the Java gumph like imports, class 
definition at the top of the generated class.

At the minute I'm thinking I can do it in the @init action on the first 
rule in the tree parser like this:

script
@init { %start(); }
: constructor function_def* EOF;

However that simply instantiates a template. Doing $st = $start(); just 
sets retval.st to be that template. What I need is some way to chain 
templates together from within an action. Is that possible? Or is there 
another, better solution for this?

Thanks!
Carl



More information about the antlr-interest mailing list