[antlr-interest] Do lists work with SteingTemplates?

Ted Villalba ted.villalba at gmail.com
Thu May 24 09:30:27 PDT 2007


Thanks.
Is there example code somewhere in the distribution that tests this sort of
+=/list construction.
I've modified my template groups so that I think I am returning a template
for value, but have witnessed no change in the list creation. Not entirely
sure of myself here, so I may not be returning a template yet.
In my Tree grammar I have:

expression : ^('=' tag (v+=value)+) ->
template4(tag={$tag.text},values={$v}) ;

value   : WCHAR+ -> template5(val={$value.text});



In my templates:

template4(tag, values) ::= "<tag>:<values>"

template5(val) ::= "<val>"



Is this returning a template for value ? I'm not sure. I don;t know how to
establish that I am returning a template for value.



Thanks again,

Ted



On 5/24/07, Terence Parr <parrt at cs.usfca.edu> wrote:
>
>
> On May 24, 2007, at 8:05 AM, Ted Villalba wrote:
>
> > Hi,
> >
> > I've sent a similar post, but perhaps this one is worded better. It
> > even includes a glossy ascii diagram.
> > I'm wondering if anyone is using the following += notation to pass
> > a list in StringTemplates. I've not had any luck getting it to work..
> > I basically have an AST with the following structure ^('=' tag value
> > +) , which creates an AST something like:
> >           =
> >      /    |     \
> >     /     |       \
> > tag value1  value2...
> >
> > I'm using a string template to pull these like so:
> > expression : ^('=' tag (v+=value)+) -> template4(tag=
> > {$tag.text},values={$v}) ;
> >
> > But this fails to pull any of the values into the list and I get
> > empty lists back. If I simply pull singular values back, and remove
> > the += list construct from the grammar, it works fine, for example,
> > the case where tag = value1. It just fails when tag = value 1
> > value2. I have not found a way to capture value2.
> >
>
> Most likely situation is that value is not returning a template.
>
> Ter
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20070524/12bdd48d/attachment.html 


More information about the antlr-interest mailing list