[英]Why c header file is not generated using ANTLR works 1.5?
我正在尝试在Windows上使用antlrworks 1.5(ANTLR 3.5)从ANTLR.grammar文件生成C代码,但它不生成任何头文件,例如sample.g,它生成:
sample.tokens
sampleLexer.c
sampleParser.c
但没有任何头文件,我不知道为什么。
举例来说,我现在使用的语法非常简单:
grammar sample;
options
{
language = C;
}
rule1:
'ABC'
;
我也收到这样的警告:
[12:39:44] warning(24): template error: context [/outputFile /parser] 1:1 could not pass through undefined attribute filterMode
[12:39:44] warning(24): template error: context [/outputFile /parser /genericParser /_sub721 /ruleAttributeScopeFuncMacro] 1:4 no such property or can't access: null.attributes
[12:39:44] warning(24): template error: context [/outputFile /parser /genericParser] 155:5 no such property or can't access: null.apifuncs
[12:39:44] warning(24): template error: context [/outputFile /parser /genericParser /rule /ruleDeclarations] 4:1 no such property or can't access: null.attributes
[12:39:44] warning(24): template error: context [/outputFile /parser /genericParser /rule /ruleInitializations] 8:1 no such property or can't access: null.attributes
[12:39:44] warning(24): template error: context [/outputFile /lexer /lexerRule /ruleDeclarations] 4:1 no such property or can't access: null.attributes
我找到了一篇关于stackoverflow上类似警告的文章:
使用Antlr-3.5-complete.jar生成OracleSQL语法的大量模板错误
(这是我发现的唯一问题,我认为它可能对未生成的头文件没有任何作用)
我将不胜感激,我想从很久以前为java创建的一些sql语法为我的c ++项目生成一些AST树,但是我被这个有趣的问题所困扰。
注意:
我还检查了所有这些文章:
http://www.antlr.org/wiki/display/ANTLR3/FAQ+-+入门+ //入门指南http://www.antlr.org/wiki/pages/viewpage.action?pageId=728 //指南有关如何安装ANTLR的信息(尽管即时通讯使用的是antlrworks,所以我真的不需要任何其他安装) http://www.antlr.org/wiki/pages/viewpage.action?pageId=29130826 // CplusTARGET(它没有支持AST树,我已经在stackoverflow上阅读过,这就是为什么我现在尝试使用c目标的原因) http://www.antlr.org/wiki/display/ANTLR3/Using+the+ANTLR3+C+Target // C TARGET https://github.com/antlr/examples-v3 //目标示例
这可能是ANTLRWorks 1.5.1已解决的错误的副作用(将在下一个〜周内出现)。
我在1.5.0中遇到了相同的问题,使用1.5.2解决了该问题。 您可以在这里下载它http://www.antlr3.org/works/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.