C++ lexer (GCC 3.1.1) requires knowledge of other C dialects
Robert Dewar
dewar@gnat.com
Fri Aug 2 07:53:00 GMT 2002
>(though they are explicitly public domain with a BSD-like copyright notice).
THat's nonsense. Something is either in the public domain or it is copyrighted.
It cannot be both. If it has a copyright notice, then it is not in the public
domain. People on this list of all lists should not misuse the phrase!
However, BSD is a perfectly acceptable Free Software license, so I don't
see a problem here from a legal point of view.
I still see a problem from a technical point of view. First I think that
LL parser generators are inherently inferior to good LR parser generators.
If you want to use automatic parser generation, a modern LR parser
generator is a much better choice (that by the way excludes YACC and
BISON :-)
The allegation that a given parser generator cannot parse a given language
is always incorrect. Why? Because in practice what you do is to adjust the
grammar to be suitable for the generator. Such adjustment is always possible.
What you do is to superset the grammar so that it is acceptable to the
generator and then let the semantic analyzer resolve differences. Nearly
all real languages are ambiguous, so some supersetting/approximation is
often necessary.
Now what you can say is that given language L and parser generator P, the
damage done to the grammar of L to get it through P is excessive (for
example, if we have to approximate the C++ grammar as follows:
CPP_Program ::= Character_Sequence
Character_Sequence ::= character | character Character_Sequence
then that's bad, it leaves too much work for the semantic analyzer :-)
I still think that writing the parser by hand makes much better sense
for the reasons I stated previously.
P.S. I know my old Berkeley mailer is not generating proper headers for
some of you, and I am trying to find a suitable replacement that works in
my context. Sorry for the inconvenience.
More information about the Gcc
mailing list