This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: cpplib: expression parser patch 2


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/

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]