So it seems ANTLR3C uses function pointers to allow users to override them if we want to write our own functions. I need to override the error reporting function:
Pointer
void(*displayRecognitionError)(struct ANTLR3_BASE_RECOGNIZER_struct * recognizer,
pANTLR3_UINT8 * tokenNames);
Function
static void displayRecognitionError (pANTLR3_BASE_RECOGNIZER recognizer,
pANTLR3_UINT8 * tokenNames);
Right now I have the following:
@lexer::apifuncs {
RECOGNIZER->displayRecognitionError = displayRecognitionErrorNew;
}
@lexer::includes {
#include "lexerData.h"
static void displayRecognitionErrorNew (pANTLR3_BASE_RECOGNIZER recognizer,
pANTLR3_UINT8 * tokenNames);
}
@lexer::members {
#include "lexerError.h"
}
with the new error code(which all works) in the file lexerError.h. I'm trying to change this by moving the error function inside the lexerData class but unfortunately I get a compile error when try to set the function pointer to the class member.
compileUnit.cpp:179:62: error: argument of type ‘void (lexerData::)(ANTLR3_BASE_RECOGNIZER_struct*, uint8_t**)’ does not match ‘void (*)(ANTLR3_BASE_RECOGNIZER_struct*, uint8_t**)’
From what I've read this isn't a simple casting or syntax problem. What should I do to allow this? One fix appears to be change the function pointer definition but I need to able to assign the function pointer to different classes as the lexer is run twice with different data structures.