将Antlr 3.5.2与StringTemplate 4结合起来以进行代码生成 [英] Combining Antlr 3.5.2 with StringTemplate 4 for code generation

查看:89
本文介绍了将Antlr 3.5.2与StringTemplate 4结合起来以进行代码生成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理的当前项目仅限于使用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选项仅支持StringTemplate3.您仍然可以支持StringTemplate 4,但它需要使用嵌入式动作或类似于WPF的手写助行器. 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆