[antlr-interest] Lexer and Parser class packaging
Martin Probst
mail at martin-probst.com
Tue Feb 6 03:15:06 PST 2007
> 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.
It's indeed counter intuitive.
If I say "At a station, you'll usually find a bus stop", it's usually
taken that I imply all sorts of stations that make sense in the
context, i.e. train stations, tramway stations, subway stations, etc.
If I want to limit the statement to "subway stations", then I'll
specify that by being explicit. This is simply a convention in human
language, and it's also logical.
I think ANTLR should follow that and put stuff that shows up in
"@header {}" in both the lexer and parser, and it should do the same
for "@member {}". While of course putting something in "@member {}"
without a qualifier is nearly always an error, it seems a lot more
sensible to me to require explicit specification if you want uh,
explicit specification ;-)
@parser::header ==> to parser
@lexer::header ==> to lexer
@header ==> to both
All @ statements without a qualification should go into all generated
products. It's also not obvious why the Parser should take such
precedence over a lexer or over any tree parser.
Regards,
Martin
More information about the antlr-interest
mailing list