[antlr-interest] Non-Default Exception-Handling - Synching to the end of the rule

Ric Klaren ric.klaren at gmail.com
Sat Dec 11 03:06:22 PST 2004


On Fri, 10 Dec 2004 17:28:12 -0800 (PST), Colm McHugh
<colmmagoo at yahoo.com> wrote:
> This may have come up before, but I am wondering if
> there is a convenient way to synch to the end of the
> rule when doing non-default exception handling ? I
> like the way the default exception handler does this,
> and it would be great if there was a simple way to
> apply this with non-default exception-handling.

Just mimick the default errorhandlers. Inside the errorhandling
section of a rule you can use the macros $FIRST $FOLLOW
$FIRST(rulename) $FOLLOW(rulename) to get access to the sets used for
error recovery. Just feed the right one to consumeUntil and you should
have gone to the 'next-rule'.

> The reason I am asking is because with non-default
> exception handling, the lookahead is not advanced, and
> multiple exceptions can be raised for the same syntax
> error.

You could also do things the other way around and leave on the default
handling and turn it off on a per rule basis depends a bit on what's
most practical. I'm afraid there's still no way to provide your own
template for a exception handler.

Cheers,

Ric


 
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