StringTemplate 4.0.2: grammar Example; start: 'Hello' NAME '!'; public class ExampleMain { public static void main(String[] args) { ExampleLexer lexer = new ExampleLexer(new ANTLRFileStream("input.txt")); ExampleParser parser = new ExampleParser(new CommonTokenStream(lexer)); ParseTree tree = parser.start(); String name = tree.getChild(1).getText(); STGroup group = new STGroupFile("template.stg"); ST template = group.getInstanceOf("helloTemplate"); template.add("name", name); String output = template.render(); System.out.println(output); } }


上一篇:
下一篇:
切换中文