[antlr-interest] [C target][HEELP :-] About disable recovery ... Override recoverFromMismatchedToken() ... Linker error

Ruslan Zasukhin ruslan_zasukhin at valentina-db.com
Thu Oct 20 14:41:35 PDT 2011


On 10/21/11 12:35 AM, "Jim Idle" <jimi at temporal-wave.com> wrote:

Okay I see ... Thank you for point.


Hmm. 

Jim, I think it will be better and simpler, if you will add right into
antlr3baserecognizer.c file this small function

void* recoverFromMismatchedToken_off(
    pANTLR3_BASE_RECOGNIZER recognizer, ANTLR3_UINT32 ttype,
pANTLR3_BITSET_LIST follow)
{
    mismatch( recognizer, ttype, follow );
    return NULL;
}


And provide for us easy way to switch to it in the @parser::apifuncs

Then WE - users of ANTLR, will need just one line to switch.
This will be good yes?  :-)



> You need to copy the mismatch locally or call it via a pointer (if it is in
> the interface, but I think it is not).

> Jim



> *From:* Ruslan Zasukhin [mailto:ruslan_zasukhin at valentina-db.com]
> *Sent:* Thursday, October 20, 2011 2:30 PM
> *To:* Jim Idle
> *Subject:* [C target][HEELP :-] About disable recovery ... Override
> recoverFromMismatchedToken() ... Linker error
> 
> 
> 
> Hi Jim,
> 
> So it seems I have realize (like prev person who did ask same)
> That  this comment is out of date and  mismatchRecover()
> was renamed to recoverFromMismatchedToken()
> 
> -----------------------------------------------------------
> /// 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.
> ///
> static void *
> match(    pANTLR3_BASE_RECOGNIZER recognizer,
>         ANTLR3_UINT32 ttype, pANTLR3_BITSET_LIST follow)
> -----------------------------------------------------------
> 
> 
> So I have try made this function as next:
> 
> void* recoverFromMismatchedToken_off(
>     pANTLR3_BASE_RECOGNIZER recognizer, ANTLR3_UINT32 ttype,
> pANTLR3_BITSET_LIST follow)
> {
>     mismatch( recognizer, ttype, follow );
>     return NULL;
> }
> 
> @parser::apifuncs
> {
>     // Install custom error message display
>     //
>     RECOGNIZER->displayRecognitionError = vdb_BuildRecognitionErrorStr;
>     RECOGNIZER->recoverFromMismatchedToken = recoverFromMismatchedToken_off;
> .......
> 
> 
> ==========================================
> *PROBLEM IS:
> *
> Method match() is declared as static  in the antlr3baserecognizer.c
> So linker of course give us error.
> 
> Then I wonder:
>     why comment says that we must call  mismatch() ?
>     how ??
> 
> 
> We should change sources of ANTLR3 ? I hope not.
> But so far I do not see other way ...
> Static method is static method ...
> 
> 

-- 
Best regards,

Ruslan Zasukhin
VP Engineering and New Technology
Paradigma Software, Inc

Valentina - Joining Worlds of Information
http://www.paradigmasoft.com

[I feel the need: the need for speed]




More information about the antlr-interest mailing list