Boost logo

Boost :

From: bill_kempf (williamkempf_at_[hidden])
Date: 2002-02-26 13:04:06

--- In boost_at_y..., Douglas Gregor <gregod_at_c...> wrote:
> On Tuesday 26 February 2002 12:28 pm, you wrote:
> > Doees anyone know of a C++-friendly version of yacc, or, better
yet, a
> > version of yacc that produces a generic algorithm (e.g., take as
input a
> > pair of InputIterators)? Yacc / bison as it stands is quite
unfriendly to
> > C++, as you cannot put C++ objects on the evaluation stack, which
> > that you can't always get objects properly destroyed. You can
> > partially get around this by putting only pointers on the
> > stack, and having the code that accompanies a production rule be
> > responsible for managing the objects on which it operates, but
this scheme
> > breaks down when it comes to error processing -- values get
popped off of
> > the evaluation stack without giving you any opportunity to
process them.
> I looked around somewhat recently for the same thing, and was
> unable to find any generic parser other than Spirit (which I
couldn't use
> only because of the fear of adding yet another library). I ended up
> Bison with lots of pointers, grumbling all the way...

Did you look at ANTLR? (

> > The Spirit parser is not what I am looking for, as it is limited
> > recursive-descent parsing, and is hence unsuitable for many
> > (say, parsing a C++ program).
> As Dave Abrahams already mentioned, several of the better C++
parsers uses
> recursive descent parsing. This is generally because recursive
> parsers handle context sensitivity and arbitrary lookahead _much_
better than
> any Yacc-based solution. Check out gcc/cp/parse.y in the GCC source
code to
> see all of the ugliness a Yacc-based parser adds; especially look
at the
> comments. Also note that there is an experimental recursive descent
> for GCC that will replace the Yacc-based parser in the future.

The ANTLR/PCCTS books have a lot to say about recursive descent

Bill Kempf

Boost list run by bdawes at, gregod at, cpdaniel at, john at