Boost logo

Boost :

From: Eric Niebler (eric_at_[hidden])
Date: 2007-04-04 03:18:11


As discussed here recently, Boost.Proto is an expression template (ET)
framework for building domain-specific embedded languages (DSEL). The
purpose of this preliminary submission is to solicit feedback prior to a
full submission (and to buy myself a little time to polish the
docs/tests/examples :-).

<< Marketing Blurb >>

Boost.Proto eases the development of domain-specific embedded languages
(DSELs). Use Proto to define the primitives of your mini-language and
let Proto handle the operator overloading and the construction of the
expression parse tree. Immediately evaluate the expression tree by
passing it a function object. Or transform the expression tree by
defining the meta-grammar of your mini-language, decorated with an
assortment of tree transforms provided by Proto or defined by you. Then
use the meta-grammar to give your users short and readable syntax errors
for invalid expressions! An expression template library developed with
Proto is declarative and readable.

In short, Proto is a DSEL for defining DSELs.

<< Hello, World >>

Here's the required hello world example in proto. It builds an
expression template and evaluates it. (The docs have more interesting
examples.)

     #include <iostream>
     #include <boost/xpressive/proto/proto.hpp>
     #include <boost/xpressive/proto/context.hpp>
     #include <boost/typeof/std/ostream.hpp>
     using namespace boost;

     proto::terminal< std::ostream & >::type cout_ = { std::cout };

     template< typename Expr >
     void evaluate( Expr const & expr )
     {
         proto::default_context ctx;
         proto::eval(expr, ctx);
     }

     int main()
     {
         evaluate( cout_ << "hello" << ',' << " world" );
         return 0;
     }

<< Documentation (such as it is) >>

http://boost-sandbox.sourceforge.net/libs/proto/doc/html/index.html

<< Download >>

proto.zip at
http://boost-consulting.com/vault/index.php?&directory=Template%20Metaprogramming

<< Requirements >>

Tested with Boost RC 1.34 and HEAD.

Feedback is most welcome.

-- 
Eric Niebler
Boost Consulting
www.boost-consulting.com

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk