结合 Antlr 3.5.2 和 StringTemplate 4 进行代码生成 [英] Combining Antlr 3.5.2 with StringTemplate 4 for code generation
问题描述
我正在处理的当前项目仅限于使用 antlr 3.5.2,但我想使用 StringTemplate 4 的功能集来生成代码.antlr 3.5.2 可以生成使用 StringTemplate 4 的 java treewalker 吗?(例如,带有 output=template 的树语法生成器会生成一个带有 ST* 引用而不是 StringTemplate* 的 java 文件)
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*)
推荐答案
output=template
选项仅支持 StringTemplate 3.您仍然可以支持 StringTemplate 4,但它需要使用嵌入式操作或类似于 ANTLR 4 自动生成的手写步行器.
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.
ANTLR 4 工具本身使用第二个选项.
The ANTLR 4 tool itself uses the second option.
这篇关于结合 Antlr 3.5.2 和 StringTemplate 4 进行代码生成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!