简体   繁体   中英

Why c header file is not generated using ANTLR works 1.5?

I am trying to generate c code from ANTLR.grammar file, using antlrworks 1.5 (ANTLR 3.5) on windows, but it doesn't generate any header files, for example for sample.g it generates:
sample.tokens
sampleLexer.c
sampleParser.c

but not any header files and i can't figure out why.

The grammar what i am using now, is really simple for the sake of example:

grammar sample;

options 
{
language    = C;
}

rule1:
'ABC'   
;

I also get warnings such:

[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

I have find an article about similar warnings on stackoverflow:
numerous template errors generating OracleSQL grammar using Antlr-3.5-complete.jar
(this is the only thing i have found out about this and i think it may not do anything about header files not being generated)

I would appreciate any help, i would like to generate some AST trees for my c++ project from some sql grammar i have made a long ago for java, but im stuck by this interesting issue.

Note:

I have also checked out all these articles:

http://www.antlr.org/wiki/display/ANTLR3/FAQ+-+Getting+Started //Starting guide http://www.antlr.org/wiki/pages/viewpage.action?pageId=728 //guide on how to install ANTLR (Although im using antlrworks, so i dont really need any other installation) http://www.antlr.org/wiki/pages/viewpage.action?pageId=29130826 //CplusTARGET (It doesn't have support for AST trees, that i have read it on stackoverflow, thats why i am trying c target now) http://www.antlr.org/wiki/display/ANTLR3/Using+the+ANTLR3+C+Target //C TARGET https://github.com/antlr/examples-v3 //Examples for targets

It's likely a side effect of a bug that's already been resolved for ANTLRWorks 1.5.1 (coming within the next ~week).

https://github.com/antlr/antlrworks/pull/9

I got the same problem with 1.5.0 Using 1.5.2 solves the problem. You can download it here http://www.antlr3.org/works/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM