protected void writeTemplateTestFile(String parserName,
String lexerName,
String parserStartRuleName,
boolean debug)
{
ST outputFileST = new ST(
"import org.antlr.runtime.*;\n" +
"import org.antlr.stringtemplate.*;\n" +
"import org.antlr.stringtemplate.language.*;\n" +
"import org.antlr.runtime.debug.*;\n" +
"import java.io.*;\n" +
"\n" +
"class Profiler2 extends Profiler {\n" +
" public void terminate() { ; }\n" +
"}\n"+
"public class Test {\n" +
" static String templates = \"group T; foo(x,y) ::= \\\"\\<x> \\<y>\\\"\";\n" +
" static StringTemplateGroup group ="+
" new StringTemplateGroup(new StringReader(templates)," +
" AngleBracketTemplateLexer.class);"+
" public static void main(String[] args) throws Exception {\n" +
" CharStream input = new ANTLRFileStream(args[0]);\n" +
" <lexerName> lex = new <lexerName>(input);\n" +
" CommonTokenStream tokens = new CommonTokenStream(lex);\n" +
" <createParser>\n"+
" parser.setTemplateLib(group);\n"+
" <parserName>.<parserStartRuleName>_return r = parser.<parserStartRuleName>();\n" +
" if ( r.st!=null )\n" +
" System.out.print(r.st.toString());\n" +
" else\n" +
" System.out.print(\"\");\n" +
" }\n" +
"}"
);
ST createParserST =
new ST(
" Profiler2 profiler = new Profiler2();\n"+
" <parserName> parser = new <parserName>(tokens,profiler);\n" +
" profiler.setParser(parser);\n");
if ( !debug ) {
createParserST =
new ST(
" <parserName> parser = new <parserName>(tokens);\n");
}
outputFileST.add("createParser", createParserST);
outputFileST.add("parserName", parserName);
outputFileST.add("lexerName", lexerName);