[antlr-interest] Error recovery contortion

Paul J. Lucas pauljlucas at mac.com
Tue Dec 7 11:34:10 PST 2004


On Tue, 7 Dec 2004, Terence Parr wrote:

> func : ID another SEMI ;
> exception
> catch [ RecognitionException re ] {
>                      ## = #([ERROR,"ERROR"]);
>                          recover( re );
>      }
> 
> another : STUFF ;
> 
> instead I see in func():
> 
>                          another();
>                          astFactory.addASTChild(currentAST, returnAST);
> 
> but if I have a catch on another(), it does the recover.  Control will 
> return normally from func() and add returnAST to the current tree, 
> right?

	Right.

> Why can't you add a catch to the equiv of another()?

	Because "another" in my case is "expression" that has a zillion
	subrules (addExpr, mulExpr, etc), and I'd have to add my own
	"catch" to *every* *single* *one* of those and end up having to
	do it to the whole grammar.  This kind of defeats the point of
	having defaultErrorHandler=true.

	The goal here is to try to mold ANTLR's default error recovery
	mechanism to do what I want so in 99% of my grammar I don't
	have to do anything special.  Only in those places where I want
	to do specific recovery do I want to intervene.

	Get it?

	- Paul



 
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