[antlr-interest] token stream resynching in custom exception handlers?

Dennis Marsa drm at xilinx.com
Fri Nov 2 07:27:28 PST 2001

How can one write a custom exception handler for a rule in ANTLR
that synchs the token stream to the follow set of the rule just
as the default exception handler does?

For example:

    :    a
    |    b  { throw MyExceptionType(...); }
    |    c
    catch [MyExceptionType& exc] {
        // Do some custom work with exc

        // Attempt to resynch the token stream
        consumeUntil(????);  // oops!
This doesn't seem possible since in the grammar file, there seems
to be no way of referring to the rule's follow set for the call to
consumeUntil().  Or is there?

Is there another strategy that I'm not seeing?

Dennis Marsa


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

More information about the antlr-interest mailing list