[antlr-interest] [antlr 3] How to use the a C lexer/parser
Boris Boucher
boris.boucher at gmail.com
Thu May 17 14:28:24 PDT 2007
Hello all,
I just begun to write a lexer/parse using antlr 3.0b7.
My problem is what are the step to be done to invoke the parser ?
I have writen the follwing code but the program crash inside the antlr C
runtime in a hash that did not seams to be allocated or initialized.
Here my code :
void parseInputFile(const std::string &fileName)
{
// create a file input stream
pANTLR3_INPUT_STREAM inputStream =
antlr3AsciiFileStreamNew((pANTLR3_UINT8)fileName.c_str());
// create the lexer
pInputParserLexer inputLexer = InputParserLexerNew(inputStream);
// create a token stream
pANTLR3_COMMON_TOKEN_STREAM tokenStream =
antlr3CommonTokenStreamSourceNew(0, inputLexer->pLexer->tokSource);
// create the parser
pInputParserParser inputParser = InputParserParserNew(tokenStream);
// call the parser
inputParser->data(inputParser);
// freeup resources
inputParser->free(inputParser);
tokenStream->free(tokenStream);
inputLexer->free(inputLexer);
// no free method on the input stream ?
free(inputStream);
}
Did I miss somethink ?
I am using Visual Studio 2005.
Boris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20070517/b957ffd5/attachment-0001.html
More information about the antlr-interest
mailing list