[antlr-interest] [C target] mismatchRecover()

Jim Idle jimi at temporal-wave.com
Tue Dec 21 11:22:49 PST 2010


It means install your own version of recoverFromMismatchedToken and
basically don't consume or insert but reset any flags etc.

Jim

> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of Justin Murray
> Sent: Tuesday, December 21, 2010 10:53 AM
> To: antlr-interest at antlr.org
> Subject: [antlr-interest] [C target] mismatchRecover()
> 
> 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
> 
> 
> 
> 
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-
> email-address



More information about the antlr-interest mailing list