[stringtemplate-interest] ST4: Pass Thru (...) support for indirect includes
Udo Borkowski
ub at abego-software.de
Sun Aug 7 00:42:43 PDT 2011
Is there a reason why indirect includes don't support Pass Thru (…)?
E.g.
t1(x) ::= "<x>"
main(x="hello",t="t1") ::= "<(t)(...)>"
will emit the following error:
t.stg 2:34: mismatched input '...' expecting RPAREN
However explicitly passing the parameter (x) with the indirect include, like in this example:
t1(x) ::= "<x>"
main(x="hello",t="t1") ::= "<(t)(x)>"
works fine.
If there is no real reason for this restriction I suggest to add "Pass Thru" support for indirect calls into the next release of ST4.
Udo
P.S.: Possibly the same applies for "named arguments" and indirect includes.
P.P.S.: here the test case:
@Test
public void testIndirectCallWithPassThru() throws Exception {
String path = tmpdir + "t.stg";
// indirectly call t1, with explicit parameter passing
writeFile(tmpdir, "t.stg",
"t1(x) ::= \"<x>\"\nmain(x=\"hello\",t=\"t1\") ::= <<\n<(t)(x)>\n>>");
STGroup group = new STGroupFile(tmpdir + "/t.stg");
ST st = group.getInstanceOf("main");
String s = st.render();
Assert.assertEquals("hello", s);
// indirectly call t1, with "pass thru" (...) parameter passing
// (used to fail with:
// "t.stg 2:21: mismatched input '...' expecting RPAREN")
writeFile(tmpdir, "t.stg",
"t1(x) ::= \"<x>\"\nmain(x=\"hello\",t=\"t1\") ::= <<\n<(t)(...)>\n>>");
group = new STGroupFile(tmpdir + "/t.stg");
st = group.getInstanceOf("main");
s = st.render();
Assert.assertEquals("hello", s);
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/stringtemplate-interest/attachments/20110807/7b1331a6/attachment.html
More information about the stringtemplate-interest
mailing list