[antlr-interest] [C target] mismatchRecover()
Justin Murray
jmurray at aerotech.com
Tue Dec 21 10:52:33 PST 2010
Hello,
I am trying to turn off single token insertion and deletion error
recovery in my parser (C target). I found the following comment in
antlr3baserecognizer.c above the match() function.
/// Match current input symbol against ttype. Upon error, do one token
/// insertion or deletion if possible.
/// To turn off single token insertion or deletion error
/// recovery, override mismatchRecover() and have it call
/// plain mismatch(), which does not recover. Then any error
/// in a rule will cause an exception and immediate exit from
/// rule. Rule would recover by resynchronizing to the set of
/// symbols that can follow rule ref.
///
This seems fairly straightforward at first glance, but then I discovered
that there is no mismatchRecover() function to override. Digging through
the code, I suspect that this function was renamed to
recoverFromMismatchedToken(), but I cannot simply override it with
mismatch() because their prototypes do not match.
void * (*recoverFromMismatchedToken) (struct
ANTLR3_BASE_RECOGNIZER_struct * recognizer,
ANTLR3_UINT32 ttype,
pANTLR3_BITSET_LIST
follow);
void (*mismatch) (struct
ANTLR3_BASE_RECOGNIZER_struct * recognizer,
ANTLR3_UINT32 ttype,
pANTLR3_BITSET_LIST follow);
As you can see, one returns a void *, and the other returns void. What
is the correct way to do this?
Thanks,
Justin Murray
Software Engineer
jmurray at aerotech.com
Aerotech, Inc.
101 Zeta Drive
Pittsburgh, PA 15238
412-963-7470
More information about the antlr-interest
mailing list