[antlr-interest] Handling Antlr Syntax Errors or how to give a better message on unexpected token
jimi at temporal-wave.com
Tue May 1 10:30:01 PDT 2012
> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of Burton Samograd
> Sent: Tuesday, May 01, 2012 8:18 AM
> To: antlr-interest at antlr.org
> Subject: [antlr-interest] Handling Antlr Syntax Errors or how to give a
> better message on unexpected token
> We have the following sub-part of an Antlr grammar:
> : SIGN? INT
> INT : '0'..'9'+
> When someone enters a numeric value everything is fine, but if they
> mistakenly type something like 1O (one and capital o) we get a cryptic
> error message like:
> error 1 : Missing token at offset 14
> near [Index: 0 (Start: 0-Stop: 0) ='<missing COLON>' type<24>
> Line: 26 LinePos:14]
> : syntax error...
> Obviously our grammar is more complex than the one given above, but
> this type of error happens when the user mistypes an integer as above.
> What is a good way to handle this type of error? I thought of defining
> a catch-all SYMBOL token type but this lead to too many parser building
> errors. I will continue looking into Antlr error handling but I
> thought I would post this here to look for some insights.
> Also asked on Stack Overflow:
> Burton Samograd
> This e-mail, including accompanying communications and attachments, is
> strictly confidential and only for the intended recipient. Any
> retention, use or disclosure not expressly authorised by Markit is
> prohibited. This email is subject to all waivers and other terms at the
> following link: http://www.markit.com/en/about/legal/email-
> Please visit http://www.markit.com/en/about/contact/contact-us.page?
> for contact information on our offices worldwide.
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-
More information about the antlr-interest