stringtemplate4
stringtemplate4 copied to clipboard
Zip map wrongly requires i0 and i in the argument list
According to the user guide:
parens(x) ::= "(<x>)"
main() ::= "<["a", "b", "c"]:parens()>"
works and actually does fine. But the following doesn't:
parens(x, y) ::= "(<x>, <y>)"
main() ::= "<["a", "b", "c"], ["1", "2", "3"]:parens()>"
The error says parens
requires i0
and i
. So the following works:
parens(x, y, i, i0) ::= "(<x>, <y>)"
main() ::= "<["a", "b", "c"], ["1", "2", "3"]:parens()>"
The same works with anonymous template as follows:
parens(x, y) ::= "(<x>, <y>)"
main() ::= "<["a", "b", "c"], ["1", "2", "3"]:{x, y | parens(x, y) }>"
If i
and i0
are intended to be available only in anonymous subtemplates (the doc seems suggesting so),
then at least the behavior must be consistent across non-zipping and zipping cases.
In non-zipping case, i
and i0
aren't required and even if we specify them, no indices are passed in.
But in zipping case, if we add i
and i0
to the argument list, the proper indices are passed in.
That's weird to me.
UPDATE: I read Interpreter.java
and for the zip_map
, if (st.impl.isAnonSubtemplate)
check around st.rawSetAttribute("i0", i0)
seems omitted by mistake. rot_map
and rot_map_iterator
have one.