[antlr-interest] error recovery in top level repeated rules?

Jim Idle jimi at temporal-wave.com
Sat Sep 8 08:53:27 PDT 2012


See FAQ regarding magic error recovery.

http://www.antlr.org/wiki/display/ANTLR3/Custom+Syntax+Error+Recovery

This, with some improvements I think (Ter?), is built in to V4.

Jim

> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of JesusFreke
> Sent: Friday, September 07, 2012 6:58 PM
> To: antlr-interest at antlr.org
> Subject: [antlr-interest] error recovery in top level repeated rules?
>
> Is there any way to recover from an error (say, an extra unwanted
> token), in a top level repeated rule?
>
> For example, consider the following simple grammar
>
> top : (('a' 'c') | ('b' 'c'))*;
>
> For input acabc", it parses 'ac', produces an error on 'a', and then
> contiues on with 'bc'. This is perfect.
>
> But for input "accbc", it parses 'ac', and then fails at 'c' and stops
> parsing. Is there any way to get it to produce an error for the extra
> 'c', and then continue on parsing the remaining 'bc'?
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-
> email-address


More information about the antlr-interest mailing list