[antlr-interest] C runtime issue
Andy Grove
andy.grove at codefutures.com
Mon Feb 2 13:37:18 PST 2009
Hi,
When I invoke my generated C parser, I see memory usage climb from 770MB to
4GB in a few seconds and the parser never returns. My init code is as
follows:
input = antlr3NewAsciiStringInPlaceStream((pANTLR3_UINT8)stringCopy,
stringLength, NULL);
if (input == NULL) {
log->error("input error");
return;
}
lexer = DbsMySQL_CPPLexerNew(input);
if (lexer == NULL) {
log->error("lexer error");
return;
}
tstream = antlr3CommonTokenStreamSourceNew(ANTLR3_SIZE_HINT,
lexer->pLexer->rec->state->tokSource);
if (tstream == NULL) {
log->error("token stream error");
return;
}
parser = DbsMySQL_CPPParserNew(tstream);
if (parser == NULL) {
log->error("parser error");
return;
}
parser->statement(parser);
I added some printf() statements to the generated code and tracked the issue
down to the "LA(1)" macro which expands to
"ctx->pParser->tstream->istream->_LA(ctx->pParser->tstream->istream, 1)". It
seems that this call never completes. Here is the code in question:
statement(pDbsMySQL_CPPParser ctx)
{
printf("statement()\n");
/* Initialize rule variables
*/
/* Empty */
{
{
// DbsMySQL_CPP.g:74:1: (i= insertStatement EOF | s=
selectStatement[true] EOF | u= updateStatement EOF | d= deleteStatement EOF
)
printf("** 1\n");
ANTLR3_UINT32 alt1;
alt1=4;
printf("** 2\n");
switch ( LA(1) ) // this call never completes
{
case INSERT:
I'd appreciate any pointers on fixing this or at least debugging it further.
Thanks!
Andy.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20090202/bd9839d7/attachment.html
More information about the antlr-interest
mailing list