[stringtemplate-interest] Parallel list iteration over a template
..... Ollio ......
ollio at gmx.ch
Sun Mar 4 12:41:43 PST 2012
Hello
I discovered stringtemplate and antler and got into a keen interest.
Rightnow I try fitting Stringtemplate to generate some PLSQL-code. Till now it took my several hours and some days and did some good progress, but now it seems I'm really stuck:
How can I do parallel iteration over severval parameterlists while calling a named template for each step?
I can see there are these anonymous inline templates that could do the work. But this lead to blobed code without any modularisation.
I'm Working with STST on CMD.EXE with a JSON Datarepositry:
$stst LPNO_TUT01.main LPNO_TUT01.js -a
----------------------------------------
LPNO_TUT01.stg
----------------------------------------
group LPNO_TUT01;
main() ::= <<
create or replace
package API$<TABLE_NAME>
--- TABLE_NAME : <TABLE_NAME>,
--- PARAMLIST : <PARAMLIST>,
--- UFLDSET_SUFFIX : <UFLDSET_SUFFIX; separator="\n--- UFLDSET_SUFFIX : ">
--- UFLDSET_PARAMLIST : <UFLDSET_PARAMLIST; separator="\n--- UFLDSET_PARAMLIST : ">
<SubA()>
<vars:{v | int <v>;}>
<SubB("suffix0")>
--- Testchunks
--- <TABLE_NAME:{v | int <v>;}>
--- <TABLE_NAME, PARAMLIST:{v, p | int <v>; float <p>;}>
--- Pre- and Posttext with anonymous inline template: 1 Parameter
<UFLDSET_SUFFIX:{v | Pretext <v> Posttext;<\n>}>
--- Pre- and Posttext with anonymous inline template: 2 Parameter, parallel interation
<UFLDSET_SUFFIX, UFLDSET_PARAMLIST:{v, p | Pretext v: <v> p: <p> Posttext;<\n>}>
---?? )-: First Try doing parallel iteration on the two Parameter-ARRAYs: :-( ????
<SHOW_4UNIQUE_FIELDSET(suffix=UFLDSET_SUFFIX, params=UFLDSET_PARAMLIST)>
---?? )-: Second Try doing parallel iteration on the two Parameter-ARRAYs: :-( ????
<UFLDSET_SUFFIX, UFLDSET_PARAMLIST:{s, p | SHOW_4UNIQUE_FIELDSET(<s>,<p>)<\n>}>
end package API$<TABLE_NAME>;
-- eof eof eof eof eof eof eof eof eof eof eof eof eof eof eof eof eof eof
>>
/*
<SHOW_4UNIQUE_FIELDSET("suffix1", "params1")>
*/
SubA() ::= <<
function SHOW_SubA()
RETURN <TABLE_NAME>%ROWTYPE;
>>
SubB(suffix) ::= <<
function SHOW_SubB_<suffix>()
RETURN <TABLE_NAME>%ROWTYPE;
>>
SHOW_4UNIQUE_FIELDSET(suffix, params) ::= <<
function SHOW_BY_<suffix>(<params>)
RETURN <TABLE_NAME>%ROWTYPE;
--- returns the %ROWTYPE or NULL if failure
--- exceptions by any constraint-violation are raised
>>
enum() ::= <<
>>
----------------------------------------
LPNO_TUT01.js
----------------------------------------
{
"TABLE_NAME" : "KATT_TAB2",
"PARAMLIST" : "T2PK1 number",
"UFLDSET_SUFFIX" : ["T2ATTR0_T2ATTR1_T2ATTR2", "T2ATTR3"],
"UFLDSET_PARAMLIST" : ["T2ATTR0 Number, T2ATTR1 Varchar, T2ATTR2 varchar", "T2ATTR3 number"]
}
---------------------
Can anyone guide me in the right direction?
Thanks
Othmar
--
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