[stringtemplate-interest] How to call a template from another when using formal args
Marziou, Gael
gael.marziou at hp.com
Mon Apr 6 10:53:43 PDT 2009
Thanks for your reply.
Equals is not a reserved word, however some of your suggestions helped me to find a solution inspired by testFormalArgumentAssignmentInApply().
The trick was to use $it$.
String templates =
"group test; " +
"zero(var) ::= \"$var:equals(value=0)$\" " +
"equals(value) ::= \"$it$ = $value$\"";
However, when I tried to use 2 formal arguments it did not work:
String templates =
"group test; " +
"zero(var) ::= \"$equals(var=$var$, value=0)$\" " +
"equals(var, value) ::= \"$var$ = $value$\"";
Then I tried to pass a constant string, still no luck:
String templates =
"group test; " +
"zero(var) ::= \"$equals(var=\"a\", value=0)$\" " +
"equals(var, value) ::= \"$var$ = $value$\"";
So I switched to "<< >>" syntax and it worked:
String templates =
"group test; " +
"zero(var) ::= <<$equals(var=\"a\", value=0)$>> " +
"equals(var, value) ::= <<$var$ = $value$>>";
I guess there is something fundamental that I did not get on passing arguments because it does work easily when I am just passing integers.
Something wrong probably with quoting.
String templates =
"group test; " +
"zero(var) ::= \"$equals(var=1, value=0)$\" " +
"equals(var, value) ::= \"$var$ = $value$\"";
Thanks,
Gael
More information about the stringtemplate-interest
mailing list