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!!

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top