[antlr-interest] Newbie: Confusion building C-Target project
Jorge Fuente-Alba
the_madman at latinmail.com
Mon Nov 5 23:45:16 PST 2007
Hi.
I have a game project, currently being developed under MinGW.
Thanks to Jim I tried Cygwin and managed to build LibAntlr3c.
Then noticed that I was having the same issues building a simple test parser because MinGW doesn't seem to like libantlr3c headers at all.
Tried building a test parser under Cygwin and got dizzy.
I've talked with the guys about building the parser using cygwin as a library and then using said library under mingw. This puts a few bumps in our build process that I'd rather not have. Cygwin forces a unix-like environment that we'd rather not use. We're happily using CodeBlocks and DevCpp before that, both rely on MinGW and we've never had trouble before.
My questions are two:
1.- Is there a reason why MinGW doesn't like libantlr3c? I read something about differences between MinGW-make and Cygwin-make. Is there a way to get libantlr3c to build under mingw?
2.- if the only way to go is to build from Cygwin and then wrap for MinGW, can anyone explain why i'm getting undefined references to '_antlr3AsciiFileStreamNew', '_inifileLexerNew', '_antlr3CommonTokenStreamSourceNew' and '_inifileParserNew' ? Can anyone help me with a proper makefile? (I suspect include and lib paths, as I just did gcc main.c)
Included: Example parser main.c and grammar
main.c
-------
#include "inifileLexer.h"
#include "inifileParser.h"
int main(int argc, char* argv[])
{
pANTLR3_INPUT_STREAM pIStream = antlr3AsciiFileStreamNew((pANTLR3_UINT8)"MyInputFile.txt");
pinifileLexer pLexer = inifileLexerNew(pIStream);
/* Not obvious: */
pANTLR3_COMMON_TOKEN_STREAM pTokens = antlr3CommonTokenStreamSourceNew(0, pLexer->pLexer->tokSource);
pinifileParser pParser = inifileParserNew(pTokens);
pParser->start(pParser);
return 0;
}
grammar: inifile.g
--------------------
grammar inifile;
options {language=C;}
start : header (rule|empty)*;
rule : STR '=' data;
data : (INTEGER | FLOAT | STR) NL;
header : '[' STR ']' NL;
empty : WS* NL;
STR : ('a'..'z' | 'A'..'Z' | '0'..'9' | ' ')*;
INTEGER : ('0'..'9')*;
FLOAT : ('0'..'9') '.' ('0'..'9') ;
NL : ('\n' | '\r');
WS : (' ' | '\t' );
--------
Thanks for any help provided, I'd really hate to end up hacking a brittle custom parser as I know the source of bugs this tends to be. Plus I'm trying to get my teachers to use ANTLR for the classes and students use mostly DevCpp around here :)
Texto: ¡Concursa y gánate un boleto doble para el show de The Police en México! http://mx.starmedia.com/thepolice/
More information about the antlr-interest
mailing list