[stringtemplate-interest] Anonymous template inside another anonymous template
Terence Parr
parrt at cs.usfca.edu
Thu Dec 2 16:33:20 PST 2010
Howdy. Can you explain more at the high level of what you're trying to do? are you passing down a recursion chain a bigger and bigger arg?
I'm finding now that when I want recursion, i'm walking the model with the template; less good. I recurse or traverse my model and build a tree of embedded templates rather than having the template invoke itself.
Ter
On Dec 2, 2010, at 2:52 PM, Morten Olav Hansen wrote:
> After more digging around, it seems that the problem is that i have
> recursive templates with the same arguments.
>
> Something like this fails:
> a(prefix) ::= <<
> <b(prefix={added_<prefix>}>
>>>
>
> b(prefix) ::= <<
> <prefix> ...
>>>
>
> but using b_prefix instead works fine.
>
> The problem I'm facing is that I have recursion, and I can't create a
> template for every possible level.
>
> Any suggestions on how to fix this?
>
> Regards,
> Morten
>
> On Thu, Nov 25, 2010 at 9:44 PM, Morten Olav Hansen <mortenoh at gmail.com> wrote:
>> Hi
>>
>> Is it possible to have an anonymous template inside another template
>> somehow? I'm trying to generate an argument to a template (which is
>> called from an anonymous template).
>>
>> I have something like this:
>>
>> <r.states: {s|<state_builder(state=s, region_ns={r<region_n>})>}>
>>
>> But i get an exception:
>> Exception in thread "main" java.lang.IllegalArgumentException: cannot
>> embed template <anonymous template argument> in itself
>>
>> I'm just passing region_ns=region_n now and adding the r on the
>> template side (and this works), but this argument will potentially
>> have several arguments concatenated together.
>>
>> Regards,
>> Morten
>>
> _______________________________________________
> stringtemplate-interest mailing list
> stringtemplate-interest at antlr.org
> http://www.antlr.org/mailman/listinfo/stringtemplate-interest
More information about the stringtemplate-interest
mailing list