[antlr-interest] crash burn on C runtime

Carter, Nathan NCARTER at bentley.edu
Thu Dec 15 14:44:02 PST 2011


I'm making some progress on my own problem (quoted below).  I've created an antlr3config.h file by hand, as I found some docs suggesting that I should do so.  I'm now trying to build a project containing the antlr C sources, my generated parser from AntlrWorks, and the main.c example on this documentation page:

	http://www.antlr.org/api/C/buildrec.html

Actually, I have not taken that file exactly as it is on that page; I needed to make two changes:
1. In place of #include <treeparser.h>, I have followed the advice in the code's comments and instead included the generated files for my language, LMParser.h and LMLexer.h.
2. Throughout that file, it uses Lang as the language name, which I have replaced everywhere with LM, the name of my language as in the code generated from AntlrWorks.

However, my build still fails, and the errors indicate that there are some identifiers that are not declared.  So I grepped for them, but they appear nowhere in the antlr sources at all, only in that one example piece of documentation!  So is that documentation out-of-date?  Is there a correct piece of documentation I should be following?

Thanks!

Nathan


$ make
g++ -x c -c -Wall -I./include/ main.c -o main.o
main.c: In function ‘main’:
main.c:73: error: ‘LMParser_decl_return’ undeclared (first use in this function)
main.c:73: error: (Each undeclared identifier is reported only once
main.c:73: error: for each function it appears in.)
main.c:73: error: expected ‘;’ before ‘langAST’
main.c:87: error: ‘pLMDumpDecl’ undeclared (first use in this function)
main.c:87: error: expected ‘;’ before ‘treePsr’
main.c:105: warning: implicit declaration of function ‘antlr38BitFileStreamNew’
main.c:105: warning: assignment makes pointer from integer without a cast
main.c:141: error: ‘struct ANTLR3_LEXER_struct’ has no member named ‘tokSource’
main.c:178: error: ‘langAST’ undeclared (first use in this function)
main.c:178: error: ‘struct LMParser_Ctx_struct’ has no member named ‘decl’
main.c:184: error: ‘struct ANTLR3_BASE_RECOGNIZER_struct’ has no member named ‘errorCount’
main.c:186: error: ‘struct ANTLR3_BASE_RECOGNIZER_struct’ has no member named ‘errorCount’
main.c:195: error: ‘treePsr’ undeclared (first use in this function)
main.c:195: warning: implicit declaration of function ‘LMDumpDeclNew’
make: *** [main.o] Error 1


On Dec 14, 2011, at 8:42 PM, Nathan Carter wrote:

> I'm replying to a thread from awhile back, which I found on Nabble.  Hope
> this is the right way to do it...just joined the list...pardon me if I have
> the customs wrong here.
> 
> The error "antlr3config.h: No such file or directory" was the OP's problem,
> and mine.  Jim Idle responded that the problem was that we just tried to
> bring in the include/ and src/ folders from the source folders, and did not
> actually install the runtime distribution.  He then pointed the OP to the
> docs.
> 
> Unfortunately, doing it that way runs counter to my eventual goals.  I'm
> trying to write code that will be incorporated into a larger project, and so
> configuring and installing antlr on my particular machine does not solve my
> problem.  Furthermore, my code is to be cross-platform, so I don't even want
> to assume antlr installations/libraries exist in particular Unix-friendly
> locations.
> 
> There must (?) be a way with a simple Makefile to get a C program that
> includes antlr-generated sources to build and run.  (Perhaps I just need to
> create a plain vanilla antlr3config.h by hand?)
> 
> Thank you for any help you can provide.
> 
> Nathan
> 
> 
> --
> View this message in context: http://antlr.1301665.n2.nabble.com/crash-burn-on-C-runtime-tp6887195p7095841.html
> Sent from the ANTLR mailing list archive at Nabble.com.
> 
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address



More information about the antlr-interest mailing list