[antlr-interest] ANTLR3 - C Targert : Error handling

Jim Idle jimi at temporal-wave.com
Wed May 30 20:32:23 PDT 2007


I wil implement a much more comprehensive error handler before too long
as the one in there is really just a place holder as we expect that each
grammar will require its own handler.

 

However, what you do is install your own error handler like this:

 

@parser::apifuncs

{

    // Install custom error message display

    //

    RECOGNIZER->displayRecognitionError = produceError;

}

 

Then your produceError function has the following signature:

 

void produceError

(pANTLR3_BASE_RECOGNIZER recognizer, pANTLR3_UINT8 *tokenNames);

 

>From whence you can crib off the source for the existing one, to do as
you wish.

 

You can do the same thing for a tree parser too.

 

However, as I said, I am going to produce an error message handler that
will do for most things, but generally "recognition error" doesn't cut
it, so I still expect you would ewant to steal the standard one and
modify it to your own ends.

 

Jim

 

From: antlr-interest-bounces at antlr.org
[mailto:antlr-interest-bounces at antlr.org] On Behalf Of Boris Boucher
Sent: Tuesday, May 29, 2007 1:50 AM
To: antlr-interest at antlr.org
Subject: [antlr-interest] ANTLR3 - C Targert : Error handling

 

Hi,

I have a working lexer/parser using the C target and all is fine is I
submit a valid text to it.

But I can't figure out how to handle error.

Right now, if I submit invalide text (at the parser level), the parser
generate an error and print out some information, then continue parsing,
re-enter the error and crash. 

Is there a mean to handle error ? Is it possible to order the parser to
continue or fail after an error ?

Boris

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20070530/a7e1384d/attachment.html 


More information about the antlr-interest mailing list