[antlr-interest] [C target] About disable recovery ... [Solution?]
Ruslan Zasukhin
ruslan_zasukhin at valentina-db.com
Fri Oct 21 01:24:03 PDT 2011
Hi All,
I want describe for archive of this list solution which I have found after 3
days learning issue.
So ... Story is.
1) I have read book ... Here info only for Java ... Overrite this. Catch
exception.. But in C no exception, so it is clear I must find info for C.
2) I jump to site -> docs -> C target ===> NOTHING ?
but should be info + example here, because C target
differs from Java. No exceptions.
3) I start search list archive... Nothing useful except last letter from
guy, which note that C comment says we must override mismatchRecover(),
But there is no such function, probably it was renamed to
recoverFromMismatchedToken()
4) Okay, I try override this function in MY ,cpp file.
But... Ops. mismatch() function, is STATIC, so I cannot link to it from my
sourcs.
Jim have suggest copy to my sources mismatch() also,
Okay I try that and ... It even not compiles, because mismatch() calls other
static funcs ...
Dirty force then: I make it in the antlr3baserecognizer.c
Compiles links ... HAPPY -> start do tests ....
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
And I see that for example such SQL query with error
"DRO TABLE T1"
Still do 3 iterations ...
Debugging shows me that I even do not get into recoverFromMismatchedToken()
Oops again...
After some debugging, I have note, that each rule, always calls recover(),
and exactly this method clears error flag.
So I do next attempt: I make own simple recover()
void vdb_recover_off( pANTLR3_BASE_RECOGNIZER recognizer )
{
return;
}
And replace default in the parser:
@parser::apifuncs
{
// Install custom error message display
//
RECOGNIZER->displayRecognitionError = vdb_BuildRecognitionErrorStr;
RECOGNIZER->recover = vdb_recover_off;
And finally !!!! It works as I want that ...
Parser builds error string and stops right on the first work DRO.
I will write also now separate letter to Terrence and Jim,
where I will try explain why such simple thing as
option RECOVER = FALSE
Should not take 3 days from users of ANTLR :)
I hope this letter will save time to future C users of ANTRL.
===================
P.S.
Also while I did learn this recover dances on ANTLR,
And read that we must override recoverFromMismatchedToken()
I have asked self:
here exists yet
recoverFromMismatchedSet(),
recoverFromMismatchedElement
recover()
Why only ONE that function should be overriden?
I think in Docs, Books, Comments, this should be explained also in clean
way. Right?
--
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