[antlr-interest] Errors in code generated by the ANTLR C target

troy runkel trunkel at gmail.com
Mon Jun 4 13:45:15 PDT 2007


Greetings,

I'm using version (ANTLR Parser Generator  Version 3.0 (May 17, 2007)
1989-2007) of ANTLR and the grammar I'm working on has the following
options set.

    language    = C;
    output        = AST;
    backtrack   = true;
    memoize    = true;

I'm seeing a number of errors in the generated C code when I try to
compile in using Visual Studio 2005.

1) The REWINDLAST macro expands to
INPUT->istream->REWINDLAST(INPUT->istream), but REWINDLAST doesn't
exist in ANTLR3_INT_STREAM_struct.  I'm assuming it's supposed to
expand to INPUT->istream->rewindLast(INPUT->istream).

2) The SEEK macro appears in the generated code but is not defined.
However I was able to find a definition for SEEK in the
antlr-3.0\src\org\antlr\codegen\templates\C\C.stg file.

I'm also working on a tree grammar and am seeing similar errors in the
generated C code for that as well.

1) I'm seeing the same REWINDLAST and SEEK macro errors mentioned above.

2) The INDEX macro appears in the generated code but is not defined.

3) The MEMOIZE macro is also used but not defined.

What am I doing wrong here?  I believe I'm working with the "official"
ANTLR v3 release, but the generated C code won't compile.

Thanks.

Troy Runkel


More information about the antlr-interest mailing list