Diego Martinez
Diego Martinez

Reputation: 69

Apply dynamic list of templates to an argument

I need apply a variable sequence of templates to an argument. The template secuence is determined in runtime in the controller layer, and these templates are applied to only one argument like:

arg:tpl1():tpl2():...:tplN()

In resume, I need apply a serie of templates to an argument, but this sequence calculated in runtime and in the controller layer.

Thank you!!

Upvotes: 2

Views: 561

Answers (1)

Terence Parr
Terence Parr

Reputation: 5962

You need to iterate over the template name and the parameter lists at the same time. From the documentation, http://www.antlr.org/wiki/display/ST4/Templates, you will find this example:

<names,phones:{ n,p | <n>: <p>}>

In your case, you need something like

<names,values:{ n,v | <(n)(v)>}>

Oh, per your comment, to apply a list of templates to another list requires a nested map-apply I think.

<values:{v | <names:{n | <(n)(v)>}}>

That applies each template named in names to each value in values.

Upvotes: 2

Related Questions