[antlr-interest] Re: tree parser generating templates

Terence Parr parrt at cs.usfca.edu
Thu Dec 15 08:46:04 PST 2005


On Dec 15, 2005, at 2:39 AM, Bryan Ewbank wrote:

> Sohail,
>
> Can you please elaborate?  I don't think I understand what you mean;
> if I do, I don't see how it would be done.
>
> How would you use a TreeParser to /generate/ a StringTemplate?

In v2, you just manually request a template for, say, assignment and  
stuff it with values.  Either return or spit out that template's  
output.  In v3, it's a bit easier but the same process:

tree grammar T;
options { output=template; }
...
assign : ID '=' expr -> assigntemplate(lhs={$ID.text}, rhs= 
{$expr.template}) ;

In this case, assign returns a template.  [actually, the $ID.text is  
broken in the tree parser for v3 at the moment, but that is my  
intention].  The assigntemplate is defined somewhere in a group file.

Ter


More information about the antlr-interest mailing list