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

Colm McHugh colmmagoo at yahoo.com
Sun Dec 12 16:39:54 PST 2004


> 
> 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'.
> 
Thanks Ric, I wasn't aware of those macros, they seem
really useful.

However, consumeUntil doesn't work in the case of
lexer exceptions; I have an expr rule and if that gets
something like 'x @ y' where @ is not a recognizable
character, I still see the same '@ - bad character'
error reported, even though my error handling code
does consumeUntil on each rule.

[I think] this is because 'consumeUntil' calls LA(1),
but if the current input is on a bad character, that's
just going to result in the same bad character
exception being thrown... I'd like something more
low-level than LA(1) to advance past the character in
this case, though I'm wary of dragging too much lexer
detail into hand-written error managing code. Time to
poke around the ANTLR header files a bit...

Thanx for the suggestion,
Colm.


		
__________________________________ 
Do you Yahoo!? 
Read only the mail you want - Yahoo! Mail SpamGuard. 
http://promotions.yahoo.com/new_mail 


 
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