[antlr-interest] StringTemplate2

Terence Parr parrt at cs.usfca.edu
Fri Sep 24 07:50:51 PDT 2004


On Sep 23, 2004, at 11:06 PM, Joan Pujol wrote:
> On Thu, 23 Sep 2004 11:36:53 -0700, Terence Parr <parrt at cs.usfca.edu> 
> wrote:
>
>>> I have a template: vardef(type,name)::= << <type> <name>; >>
>>> And code like:
>>>    vardef.setAttribute("type","int");
>>>    vardef.setAttribute("name","i");
>>>    vardef.setAttribute("type","char");
>>>    vardef.setAttribute("name","c");
>>>
>> Hmm...you need to use the separator="\n" which would require that you
>> apply vardef to a bean.  instead, just do this:
>>
>> vardef(type,name)::= <<
>> <type> <name>;
>>>>
>> newline before >> is the key. :)
>>
>> Ter
>
> A lot of thanks Ter, but it doesn't work.
> If I appy this code to your template:
>
> vardef.setAttribute("type","int");
> vardef.setAttribute("name","i");
> vardef.setAttribute("type","char");
> vardef.setAttribute("type","c");
>
> I get:
> intchar ic;
> (newline)
>
> And what I want is
> int i;(newline)
> char c;(newline)
> (and without using beans)

Oh.  Right.  You are setting two parallel arrays essentially.  I have 
no mechanism to walk them at this point (in a really old version I did 
before properties).  Only way is to have it pull from beans and use 
separator.  Are you aware of the

setAttribute("decl.{type,name}", "int", "i");

notation?  It kicks ass.  Dont' have to create your own beans.

Ter





 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
    antlr-interest-unsubscribe at yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



More information about the antlr-interest mailing list