[antlr-interest] Handling Errors

Tiller, Michael (M.M.) mtiller at ford.com
Mon Feb 14 14:31:00 PST 2005


I'm parsing something with a Java parser generated from ANTLR.  I get
messages to standard error that look something like this:

line 35:3: unexpected token: ...

>From what I have been able to find, it seems that ANTLR refrains from
throwing an exception in this case because it attempts to recover.
Furthermore, if it threw an exception, it wouldn't really be feasible to
allow the user to catch the exception and then resume from that point.
The problem is that I'd like to be strict.  If such errors occur, I'd
prefer that it did throw an exception (wouldn't the resulting AST be
considered dubious anyway?).  Is there an easy way to do this.

I'm particularly concerned about this when trying to write JUnit cases
for the parser.  If it silently continues, I have no way to check
whether it is properly detecting syntax errors, etc.

Perhaps I'm missing something?

--
Mike

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20050214/4ee5eea2/attachment.html


More information about the antlr-interest mailing list