[antlr-interest] syntactic predicates and exceptions

Don Caton dcaton at shorelinesoftware.com
Wed Oct 19 16:08:34 PDT 2005


Martin: 

> Ehm, at this place I got to raise a voice. We - and many 
> others apparently - are using ANTLR in a server setup. E.g. 
> there will be incorrect language statements while the 
> application built on top of the server is being developed, 
> but few to none afterwards (at least is certainly hope so). 
> So a failing query is a truly exceptional case.

Sure, but I did say "with human generated input".  Machine generated input
no doubt will be correct most of the time, and an error in the input might
be considered an exceptional condition.

On the other end of the scale, you could be using an Antlr-generated parser
for syntax highlighting in an editor.  In that case the percentage of bad
input is probably very high, unless you're a really good typist and you
never made coding errors.

> Meaning: get rid of of exceptions for backtracking if you 
> want to (we don't use backtracking anyways, to be honest) but 
> feel free to keep them for failing source files. A file that 
> is incorrect in terms of the language is an exceptional case 
> for a parser, and those exceptions are valid.

I wish I could get rid of backtracking, but it's not always possible.  I've
spent a lot of time trying to get rid of as many as I can but sometimes
there just doesn't appear to be any other alternative.

I disagree that a "failing source file" is an exceptional case.  Consider
the syntax highlighting scenario I mentioned above.

Given that Antlr can be used in widely different scenarios, it can't be
everything to everyone.  But if there's an alternate way to accomplish
something without throwing exceptions, why not do it the more efficient way?
That's always a good thing.

Don




More information about the antlr-interest mailing list