我想从ANTLR.grammar文件生成c代码,在Windows上使用antlrworks 1.5(ANTLR 3.5),但它不会生成任何头文件,例如sample.g,它会生成:
sample.tokens
sampleLexer.c
sampleParser.c为什么c头文件不是使用ANTLR生成的1.5?
但没有任何头文件,我不明白为什么。
我现在所使用的语法,是举例的目的很简单:
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
我找到类似的警告文章(这是我发现的唯一一件关于这件事,我认为它可能不会产生任何关于头文件不生成)
我将不胜感激任何帮助,我想为我的C++项目生成一些AST树,我从很早以前就已经为java做了一些sql语法,但是我被这个有趣的问题困住了。
注:
我还检查了所有这些文章:
http://www.antlr.org/wiki/display/ANTLR3/FAQ+-+Getting+Started //开始上如何安装ANTLR 引导 http://www.antlr.org/wiki/pages/viewpage.action?pageId=728 //指南(虽然使用IM antlrworks,所以我并不真正需要任何其他安装) http://www.antlr.org/wiki/pages/viewpage.action?pageId=29130826 // CplusTARGET(它没有对AST树的支持,我已经阅读它计算器,这就是为什么我试图现在ç目标) http://www.antlr.org/wiki/display/ANTLR3/Using+the+ANTLR3+C+Target // C TARGET https://github.com/antlr/examples-v3 //考试实现对象
你好,感谢您的帮助,我试图在eclipse中构建项目与目标包,我得到它建立成功,但是当我启动antlrworks-1.5.1-SNAPSHOT.jar我马上得到一个java异常。我能以某种方式构建项目并立即使用它吗?有没有其他的方法让windows从语法中生成c文件? –
我目前正在使用它作为eclipse的运行,并且如你所说问题已经消失,但我可以从那里建立一个超级罐子吗?如果是,请给我一些指示? –
你解决了你的问题吗?我得到相同的消息.. :( –