我刚开始学习字符串模板,我遇到了这里显示的示例:
group simple;
vardef(type,name) ::= "<type> <name>;"
method(type,name,args) ::= <<
<type> <name>(<args; separator=",">) {
<statements; separator="\n">
}
>>
我想要做的是将一个字符串模板作为参数传递给方法字符串模板,如下所示:
statements(function, arguments) ::= <<
<function>(<arguments; separator=",">);
>>
method(type,name,args, <statements> ) ::= <<
<type> <name>(<args; separator=",">) {
<statements; separator="\n">
}
>>
然而这并没有成功,所以我猜测它不可能将字符串模板传递给字符串模板?那么语句是如何填充的呢?
尝试此操作时出现以下错误:
mytemplate.stg 14:26: invalid character '<'
mytemplate.stg 14:36: invalid character '>'