Boost logo

Boost :

From: Vesa Karvonen (vesa.karvonen_at_[hidden])
Date: 2001-05-21 09:59:12

From: "Vladimir Prus" <ghost_at_[hidden]>
> joel de guzman wrote:
> > Spirit is an object oriented recursive descent parser generator
> > I wonder if anyone out there would be interested in such a beast.
> > If anyones's interested, I'd be very glad to boostify the code
> > and collaborate with people.
> This is interesting, but probably is not usefull.
> With small grammars this might work,

This is exactly the reason why I completely disagree on the usefulness
point. I haven't yet had the time to analyze the spirit generator, but if my
hunch is correct, it can make implementing micro parsers an order of
magnitude more intuitive and simpler compared to traditional methods.
Consider, for example, the operator>> for complex presented in TCPL. The
following is copied from the book for exposition.

    istream& operator>>(istream& s, complex& a)
      input formats for a complex ("f" indicates a floating point number):
      // 16 lines of code implementing the operator

Now lets turn the comment into pseudo code:

    istream& operator>>(istream& s, complex& a)
        Terminal<double> re, im;
        Parser parser = re
                      | '(' + re + ')'
                      | '(' + re + ',' + im +')'

        s >> parser;

        return complex(re,im);

The above pseudo code is something I dreamed in early 1999.

> Template metaprograms are very hard to write, debug and use.

True, but the problems are solvable and the benefits are clear.

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