[antlr-interest] C/C++ questsion posted to Wiki

Jim Idle jimi at temporal-wave.com
Sat Aug 23 10:11:12 PDT 2008


Somoen posted questions to the Wiki rather than examples/advice etc.
Please note that the Wiki isn't the place to post questions (unless you
are adding FAQs), so in answer to the notes posted there:

The 5 minute intro is intended to be used with antlr 3.1. if you get an
error that looks like this:

In file included from SimpleCalcLexer.c:16:
SimpleCalcLexer.h:112: error: parse error before
"pANTLR3_RECOGNIZER_SHARED_STATE" }}
SimpleCalcLexer.c:270: error: parse error before
"pANTLR3_RECOGNIZER_SHARED_STATE"
SimpleCalcLexer.c: In function `SimpleCalcLexerNewSSD'

I am not sure what this was explaining/asking but I think that this just
means you either generated the code with the wrong jar or compiled it
against the wrong version of the C headers.

When I built the runtime C libraries using ./configure and make, it
added the \-m32 flag. When I linked, I got an error claiming the library
is not compatible. I run on suse64.

Please use configure --help. There you will find the --enable-64bit
option. Because gcc will compile in the default binary mode of the
system, -m32 is added automatically. This isn't how most of the other
compilers work, in that they will always produce 32 bit, even on a 64bit
architecture. Hence, the 64 bit flag enables the compiler settings for
whatever compiler you are using (if configure knows about it). SO, you
should NOT add -m32 with gcc as that is the default build with ANTLR. To
get 64 bit libraries use --enable-64bit. NOte also the option to include
or exclude the ANTLR debugger, which allows the build of libraries
without socks dependencies.

Antlrworks is Antlr 3.0 based. The generated output will compile, but
when you try to link, the linker will complain about 'TOKENSOURCE(lex)'

ANTLRWorks is only designed to work with Java. Always generate your C
parsers externally and then debug remote. You need ANTLRWorks 1.2b5 to
work with 3.1 grammars.

Once you compile and link it, the C version of the 5 minute demo expects
a file name to be passes as the first argument. If you don't give it an
arg, it will seg fault.

This is a bug, it should probably check for that - however it is just
demo code of course.

Even if you do give it an arg, it doesn't print anything out. I don't
know enough to fix this or the previous problem.

Well, if you look at the grammar, it isn't designed to print anything
out.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080823/5248a0f4/attachment.html 


More information about the antlr-interest mailing list