[antlr-interest] Catching multiple errors in a tree parser

Jim Idle jimi at temporal-wave.com
Thu Nov 26 11:59:52 PST 2009


Heiko,

If there are structural errors in your tree, then it is indeed a programming mistake and recovery in a tree parser does not usually make any sense as you are responsible for making sure it is a valid tree. So, you should debug the parsers that produce the tree. If you have some very special case where you feel that recovery in the tree parser is valid, then you would have to implement the special recovery yourself by overriding the relevant methods in your tree parser (use a superClass=xxx; option to do this) as there is no generic way to know what makes sense recovery wise in tree parsers (well not one that makes much sense to me anyway ;-).

If you mean that the errors are semantic errors, then you need to implement your own error log. I generally implement a universal log that the lexer, parsers and walkers can all contribute to, extracting relevant information from text, offsets, tokens and nodes. The lexers and parsers can also contribute to the log via an override of displayRecognitionError, but the AST walker is all semantic action based errors.

Jim

> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of Heiko Folkerts
> Sent: Thursday, November 26, 2009 1:37 AM
> To: antlr-interest at antlr.org
> Subject: [antlr-interest] Catching multiple errors in a tree parser
> 
> Hi all,
> I want to catch more then one error within my tree parser. I read
> somewhere that tree parsers don't recover from the first error since
> parsing errors in tree grammars are the programmers fault. Have I got
> that wrong?
> 
> Since we use several parsers to create and validate our AST sometimes
> we have to report more than one error from within the tree parser but
> only the first one is reported via the displayError routine.
> 
> So my question is: how can I make the parser report every error that is
> encountered instead of only the first?
> 
> For our errors we create exceptions and attach the info we need to the
> custom pointer from within the grammar.
> 
> Regareds
> Heiko
> 
> 
> Mit freundlichem Gruß
> Heiko Folkerts
> Systementwicklung und -design
> --
> ______________________________________________
> DAVID GmbH · Wendenring 1 · 38114 Braunschweig
> Tel.: +49 531 24379-14
> Fax.: +49 531 24379-79
> E-Mail: mailto:Heiko.Folkerts at david-bs.de
> WWW:   http://www.david-bs.de
> Eintragung: Amtsgericht Braunschweig, HRB 3167
> Geschäftsführer: Frank Ptok
> ______________________________________________
> 
> 
> 
> 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