[antlr-interest] updated "antlr 2 bashing list"

Terence Parr parrt at cs.usfca.edu
Tue Mar 9 15:39:52 PST 2004


On Mar 9, 2004, at 12:03 PM, Robin Debreuil wrote:

> Well, I like it a lot already - have to say that first : ).
>
> One thing I find strange is using exceptions for flow control in the
> generated code. I prefer exceptions to just be used for things you 
> aren't
> expecting in code, probably that is just a style thing though. Just 
> this way
> they seem to be much like gotos with global variables for state...

"Exceptions are for exceptional conditions and not for control-flow" is 
a great rule....unless you are automatically generating that code.  The 
syn pred mechanism is meant to be used sparingly because it has 
exponential complexity when they start to nest.  The extra catch 
overhead (which is only invoked upon failure) is not a huge part of 
that I'd wager.  Further, I find the try/catch more readable than say 
wrapping all method calls in

boolean failed = rule();
if ( failed ) { ... }

also makes it kind of hard to return values efficiently.   i agree that 
it might be interesting to look at the two different approaches.

I'm adding the rest to the list... thanks...

Ter

> For the C# version, it would be really nice to use Enums for all the 
> tokens,
> or better yet, categories of them. It makes debugging much easier, and 
> the
> whole thing becomes a bit more 'solid'.
>
> Above all though, it would be great to have more error information
> available, both in the grammars and when running the generated code. 
> The
> program itself is designed to facilitate building that kind of thing 
> into
> languages, so it seems kind of like the cobblers kids going without 
> shoes.
> Maybe restrict what is valid syntax in a grammar and catch more common
> errors. For the generated code, maybe a debug version - where it can 
> tell
> you things like the statement that it couldn't get past etc. Maybe even
> things like setting breakpoints on input files.. Probably that would be
> hard, but with all the guessing levels, gotos, exceptions, etc, it can 
> get
> pretty hard to trace. I may be overlooking a few exisiting techniques 
> here
> though, I'm pretty new to it.
>
> Regardless, it is a great tool - the above would only make it easier (I
> think anyway) to do what is already pretty easy, considering...
>
> Cheers,
> Robin
>
>
>
>
>> Folks,
>>
>> Keep that hate mail coming ;)  Thanks for all the words of
>> encouragement also :)  I have updated the page to include your
>> comments:
>>
>> http://www.antlr.org/blog/antlr3/antlr2.bashing.tml
>>
>> Terence
>> --
>> Professor Comp. Sci., University of San Francisco
>> Creator, ANTLR Parser Generator, http://www.antlr.org
>> Cofounder, http://www.jguru.com
>> Cofounder, http://www.knowspam.net enjoy email again!
>> Cofounder, http://www.peerscope.com pure link sharing
>>
>>
>>
>>
>>
>>
>> Yahoo! Groups Links
>>
>>
>>
>>
>>
>>
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
--
Professor Comp. Sci., University of San Francisco
Creator, ANTLR Parser Generator, http://www.antlr.org
Cofounder, http://www.jguru.com
Cofounder, http://www.knowspam.net enjoy email again!
Cofounder, http://www.peerscope.com pure link sharing





 
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