问题
Current project I'm working on is limited to using antlr 3.5.2, but I would like to use the featureset of StringTemplate 4 for our code generation. Can antlr 3.5.2 generate a java treewalker that uses StringTemplate 4? (e.g. a tree grammer with output=template that results in a java file with ST* references instead of StringTemplate*)
回答1:
The output=template
option only supports StringTemplate 3. You can still support StringTemplate 4, but it would require using embedded actions or a hand-written walker similar to the ones ANTLR 4 generates automatically.
The ANTLR 4 tool itself uses the second option.
来源:https://stackoverflow.com/questions/24527314/combining-antlr-3-5-2-with-stringtemplate-4-for-code-generation