[antlr-interest] Lexer and Parser class packaging

Brian DeVries contingencyplan at gmail.com
Mon Feb 5 16:17:52 PST 2007


As an ANTLR newbie ;-), I've run into this exact problem myself.

Personally, I think keystrokes are (relatively) cheap, so making the user be
explicit about where things go isn't a bad way to do it, even if it means
having @parser::members and @lexer::members too. Having the "anonymous"
@header automatically map to one or the other (parser, in the current form)
seems counter-intuitive, while only having the explicit specifications gives
the system a more "symmetric" feel. If there's an inconsistency, as
mentioned by Dr. Parr, then we should make the system consistent, all the
way, as much as possible.

As Mr. Probst put it, it's definitely a newbie trap. While it's easy (and
certainly true) to just respond with a "Read The Fine Manual," I'm in
agreement with one of my undergrad professors, Dr. Daniel Cooke: programming
languages should be adapted to people, not the other way around
(paraphrase).

Changing to use @parser::header and @parser::members doesn't require a
change in the language semantics. Both the parser and lexer have a header,
and both have members. Requiring @parser::header simply makes it explicit
which you mean, and eliminates a point of ambiguity, especially for people
who are just starting out with the system.

Thanks,
~Brian DeVries
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20070205/7b001970/attachment.html 


More information about the antlr-interest mailing list