[stringtemplate-interest] Parallel list iteration over a template
..... Ollio ......
ollio at gmx.ch
Mon Mar 5 01:26:56 PST 2012
Hello Ter
thank you very much for your quick response and your hint. It help me to work out my problem, also I had to slightly modify the suggested term.
The solution of the problem is attached below. As you can see from the formatting of the rendered output I'm still at the beginning of my learning curve.
I put some comments directly in the outputgeneration below. Maybe the online documentation concerning parallel list iteration in "Stringtemplate Cheat Sheet" would deserve some more detail information about that matter. I was also doubted because the talk there is about anonymous template (inline code between the curly brackets?) I intended to use a named template instead.
Thanks again
Othmar
Othmar Lippuner
Switzerland
File LPNO_02.js
------------------------------------------------------------------------
{
"list1" : ["A0_A1_A2", "A3"],
"list2" : ["A0 Number, A1 Varchar, A2 varchar", "A3 number"]
}
File LPNO_05.stg
------------------------------------------------------------------------
group LPNO_05;
/* USAGE: stst LPNO_05.main LPNO_02.js -a
*/
main() ::= <<
<list1:{s | <foo1(ps=s)>}>
-- done 1
<list1:{s | <foo1(s)>}>
-- done 2: implicit parameterpassing acutalparameter s to formal parameter ps works !!
-- this only works with one single parameter
-- all other parameter passing must be done in the acutual template-Call
-- by explicit assingment of actual to formal parameters
-- order of the parameters passed has no meaning for STRINGTEMPLATE
-- this violated my generativ grammatic experience(*) from PASCAL, MODULA and VBA and
-- now requires cognitive reprogramming my programmers mind ;-o
-- (*) vgl Noam Chomsky ;-)
<list1,list2:{s,p | <foo2(ps=s,pp=p)>}>
-- done 3
<list1,list2:{s,p | <foo2(pp=p, ps=s)>}>
-- done 4 with different order in actual parameterlist
<list1,list2:{s,p | <foo2a(s=s,p=p)>}>
-- done 5
>>
foo2(ps,pp) ::= <<
function SHOW_BY_<ps>(<pp>)
RETURN null;
<\n>
>>
foo2a(s,p) ::= <<
function SHOW_BY_<s>(<p>)
RETURN null;
<\n>
>>
foo1(ps) ::= <<
function SHOW_BY_<ps>()
RETURN null;
<\n>
>>
-------- Original-Nachricht --------
> Datum: Sun, 4 Mar 2012 18:41:52 -0800
> Von: Terence Parr <parrt at cs.usfca.edu>
> An: "..... Ollio ......" <ollio at gmx.ch>
> CC: stringtemplate-interest at antlr.org
> Betreff: Re: [stringtemplate-interest] Parallel list iteration over a template
> hi. Welcome Othmar.Can you narrow this down to a much smaller problem.
> there is a lot of stuff in there and I'm not sure which parallel walk you want
> to do. to me it sounds like you want something like
>
> <list1,list2:{a,b | <foo(a,b)>}>
>
> Ter
--
NEU: FreePhone 3-fach-Flat mit kostenlosem Smartphone!
Jetzt informieren: http://mobile.1und1.de/?ac=OM.PW.PW003K20328T7073a
More information about the stringtemplate-interest
mailing list