[antlr-interest] syntactic predicates and exceptions

Nigel Sheridan-Smith nbsherid at secsme.org.au
Thu Oct 20 17:26:05 PDT 2005


> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of Gerrit E.G. Hobbelt
> Sent: Friday, 21 October 2005 10:24 AM
> To: antlr-interest at antlr.org
> Subject: Re: [antlr-interest] syntactic predicates and exceptions
> 
> 
> 
> Bottom line: I suggest: cop out by offering both: generated code
> - with exceptions at any location where they're handy codesize-wise (Antlr
> On A Conditionals Diet(tm)), and
> - without any, for those that need 'Low On Clockticks(tm)' Health Code
> With
> Extra Fiber for high-performance and/or specific embedded environments
> (e.g.
> where exceptions are severily frowned upon as per company policy).
> Both versions do not need to be maintained by the same people, thus
> spreading the workload. And, yes, I realize this adds to the complexity of
> the antlr package as a whole. So be it.
> 

I agree with this entirely, but it really just comes down to how much more
complex is the code generated going to be. If you end up with something like
(as suggested by Martin):

if (!match(ID))
{ 
  return false;
}

then that is much more readable than 5+ levels of nesting of
ifs/breaks/continues/gotos/etc. If it is going to be that simple, then there
is not any loss in readability (it may actually be in increase in
'understandability', since the error handling is explicit), so exceptions
will not be any better in this department.

So once everyone (more likely, Terence, unfortunately) comes up with the
suitable replacement for exceptions, then its just a matter of judging how
much obstruction there would be, and how important this is to the ANTLR
users/community.

Nigel

--
Nigel Sheridan-Smith
PhD research student

Faculty of Engineering
University of Technology, Sydney
Phone: 02 9514 7946
Fax: 02 9514 2435



More information about the antlr-interest mailing list