Combining Antlr 3.5.2 with StringTemplate 4 for code generation

怎甘沉沦 提交于 2020-01-05 13:09:37

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!