[antlr-interest] Re: Real examples of error recovery

Ric Klaren klaren at cs.utwente.nl
Tue Aug 24 12:58:31 PDT 2004


On Tue, Aug 24, 2004 at 05:43:34PM -0000, Paul J. Lucas wrote:
> I have two lexers: (1) for "main" XQuery content and (2) for embedded XML content.  Yes, I 
> am using a tokenstream selector.

That's good I got the wrong impression for a sec so I just asked to be sure
;)

> > Tack something like this after the rule:
> > 
> > rule: .... ;
> > exception catch [antlr::RecognitionException &ex]  { }
> 
> Well, I do still want to report the error.

After you caught it you can report it in the way you want or massage it a
bit and rethrow for later reporting.

> > You can use the $FOLLOW/$FIRST sets inside the exception
> > handler or $FOLLOW(rule) $FIRST(rule) to do calculations outside of a rule.
> 
> I've never seen any mention of those.  Any documentation or examples?

They're somewhat recent additions. It could be that the docs didn't get
updated for them. Basically they're just macro's that expand to the bitsets
ANTLR uses internally. Look at the BitSet classes for the API's on them.
You can do things like consumeUntil($FOLLOW) which gives basically antlr's
default error handling if I'm not mistaken.

> > There's probably a load of papers available on the net on recovery
> > strategies.
> 
> I tried a search for 'ANTLR "error recovery"' and didn't find anything
> interesting.

Leave out the ANTLR from the search term. Antlr only has it's default
strategy you get with defaultErrorhandler=true and what you program for it
in the exception handlers.

Cheers,

Ric
-- 
-----+++++*****************************************************+++++++++-------
    ---- Ric Klaren ----- j.klaren at utwente.nl ----- +31 53 4893755  ----
-----+++++*****************************************************+++++++++-------
  "You know how to use that thing?" [pointing to the sword]
  "Sure.. The pointy end goes into the other guy."
  --- The Mask of Zorro



 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
    antlr-interest-unsubscribe at yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 





More information about the antlr-interest mailing list