[antlr-interest] Re: stuff I don't like about ANTLR 2.x
cj_daly at yahoo.com
Mon Mar 8 12:51:55 PST 2004
Here are a few:
0) (I thought of this last but I'm adding it at the beginning because
it's so important to me!). Those of us wanting to use Antlr within a
corporate environment have to do something to make the laywers happy.
I think the singlemost important thing you can do here is to have a
mechanism for registering contributers. Each contributer should be
reachable (email is fine but the more contact info you have the
better) and should have made some kind of affirmation that they agree
with the license (this affirmation could be an email that you print
and save, but a signed form faxed or snail-mailed would be even better).
I suggest looking at some of the bigger open source projects like
Mozilla or Eclipse or Apache to see what mechanisms and forms they use.
Laywers would be even happier if the contributers all assign their
copyrights to one person (i.e. Terence) or entity (like U of S.F.) but
I don't think this is necessary as long as all of the contributers are
contactable (and there aren't so many that it becomes extremely
difficult to contact them all).
Beyond that, you mentioned before that you are considering BSD as the
license. That would work for me. GPL or LGPL would totally disallow
me from using Antlr. CPL (the license Eclipse uses) would be ideal
for me but BSD is very doable.
Here are the more technical suggestions:
1) Ignore options that Antlr doesn't care about. Warning about
unknown options is ok, but don't just bail out. I have some cases
where I am parsing the .g files to generate some code that works with
the generated parser. So I want to be able to define my own options
that my tool looks at but Antlr ignores.
2) never call System.exit()! Throw an exception instead.
3) I second your #6, "Labels are unique to a Rule". I would also
recommend replacing the name:TOKEN syntax with name=TOKEN. Using the
colon in that context can cause some head-scratching bugs. Look at
the rule(s) below and see what can happen now when you forget the
semicolon at the end of a rule.
rule1 : a b
rule2 : X;
4) When a parser refers to an undefined token complain about it. For
example the following test case compiles without error even though
token DASH is not defined anywhere:
class TestParser extends Parser;
sos : s o s;
s : DOT DOT DOT;
o : DASH DASH DASH;
class TestLexer extends Lexer;
DOT : '.';
5) I'd like to see a better system for managing parsers and lexers in
separate files. I don't have any specific ideas here, just the
feeling that the TokenTypes files introduce an unnecessary extra level
6) I want to second what Monty said:
] I would like to be able to trace a Token all the way back
] to file offsets so I could modify files in place, not have
] to regenerate them entirely. That's not so easy with Unicode.
I think Token offset is a more fundamental concept than line/column.
If the latter are available then the former should be too.
7) Some way of using a literal without adding it to the literals
table. I always end up with rules enumerating the keywords that are
also legal identifiers, like:
id: ID | "foo" | "bar";
There could be some syntax like "foo"# that means don't (or do) add
this to the table.
Well that's my brain dump for now. I just want to add that Antlr,
even now, is a fantastic tool. My hat is off to Terence and all of
the other contributers and I greatly look forward to 3.0!
--- In antlr-interest at yahoogroups.com, Terence Parr <parrt at c...> wrote:
> In preparation for the ANTLR 3.0 whitepaper, I need to start writing
> down everything that annoys me about ANTLR 2.0. I have started another
> "blog" document:
> Feel free to send in your pet peeves to me or to this list. I will try
> to add to this file.
> I can hear John Mitchell now: "predicate hoisting!" ;)
> 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:
<*> To unsubscribe from this group, send an email to:
antlr-interest-unsubscribe at yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
More information about the antlr-interest