This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: cpplib: expression parser patch 2
- To: Horst von Brand <vonbrand at sleipnir dot valparaiso dot cl>
- Subject: Re: cpplib: expression parser patch 2
- From: Per Bothner <per at bothner dot com>
- Date: 31 Mar 2000 23:43:32 -0800
- Cc: gcc-patches at gcc dot gnu dot org
- References: <200004010124.e311ONR01652@sleipnir.valparaiso.cl>
Horst von Brand <vonbrand@sleipnir.valparaiso.cl> writes:
> Is cpp using operator precedence parsing? Why not bison(1)?
Why? I personally dispise yacc/bison. As soon as you have a non-trivial
grammar (C++, Java, Chill) you end up with a mess of kludges. (It is
now generally accepted that it was a mistake to use a yacc-style
grammar for C++.) And error recovery is a pain, as is debugging. The
main advantage of a yacc grammar is that it is more structured and
readable, and it can help prevent silly bugs. The problem is that
once you do need to make a non-trivial change it's almost impossble.
Also, as Neil said: cpplib is a library. Traditionally, you can only have
a single yacc grammar in a program. Thus it is not acceptable for a
library to require its own yacc grammar.
Finally, I thought cppexp was a good excuse to write an
operator-precedence parser. It was an interesting exercise for me,
and it may be useful pedagogically for others to see a real
operator-precedence grammar in real use.
--
--Per Bothner
per@bothner.com http://www.bothner.com/~per/