[antlr-interest] Possible bug in C runtime: Unable to override emit() in lexer

Michael Carns mike at carns.com
Tue Apr 26 00:41:36 PDT 2011


In order to use a customized token type, I believe I need to override
emit() and emitNew() within my ANTLR3_LEXER instance.  However, my
function isn't getting called.  I'm using version 3.1.3 of the C runtime.

The culprit appears to be this call to emit() within nextTokenStr() in
antlr3lexer.c:

Line 268:
                if (lexer->rec->state->token == NULL)
                {
                    // Emit the real token, which adds it in to the
token stream basically
                    //
                    emit(lexer);
                }

Shouldn't it be "lexer->emit(lexer)"?  As written, the call to emit()
will bind to the local version of emit() within antlr3lexer.c and won't
call my customized version.  I've looked at more recent versions in the
source repository, and the code appears to be unchanged.  Is this a real
bug, or am I going down the wrong road in my attempt to customize the
generated tokens?

Thanks,
Mike Carns



More information about the antlr-interest mailing list