[antlr-interest] syntactic predicates and exceptions

Don Caton dcaton at shorelinesoftware.com
Tue Oct 18 11:45:53 PDT 2005


Ter: 

> > Exceptions should be used for just that: exceptions.  A rule that 
> > fails to match is not an exceptional condition,
> 
> Hi Don! :)
> 
> Really?  When was the last time an HTTP server got a bad GET 
> request from a browser?  That said, I'm sure the java 
> compiler sees 99% erroneous programs from my students? ;)

Ok, point taken; there's no hard and fast rule for what constitutes an
"exception" condition.  

But IMO, if something can be expected to happen with a certain regularity in
the normal course of an activity, it isn't an exception.  An out of memory
condition is usually not the norm.  A file not found error is more common,
so whether something like that is an exception could be argued either way.  

But when it comes to parsers, it's almost a sure thing that input is going
to fail more often than it doesn't.  At least with human-generated input.

> Agreed, but parse errors are errors if ya ask me...

Errors yes, but not exceptions.  Would probably be a moot point if exception
handling wasn't so expensive. 

> 
> Perhaps you're right though: adding some IFs won't be that bad.
> 
> Ter
> 




More information about the antlr-interest mailing list