Boost logo

Proto :

Subject: [proto] vararg + fold
From: Christophe Henry (christophe.j.henry_at_[hidden])
Date: 2010-07-21 07:43:14


I want a grammar B which parses a comma-separated list of expressions
matching another grammar A and returning a mpl::vector of expressions
transformed using A. Something like:
(AExpr, AExpr, ...).

I managed to do it this way:

struct A...

template <class T>
struct make_vector
    typedef boost::mpl::vector<T> type;

struct B
   : proto::or_<
        proto::when <
        proto::when <
                        A(proto::_right) >()

This seems to work but shouts for a fold so I tried:

struct B
   : proto::when <
          proto::comma< A,proto::vararg<A> >, // => probably wrong
            , ::boost::mpl::vector<>()
            , ::boost::mpl::push_back<proto::_state, A(proto::_) >()

This seems to work in most cases (I suppose by sheer luck) but doesn't
parse correctly if no comma at all: (AExpr)
So I suppose that at least the first part of when is wrong.
Any idea how to make it work?



Proto list run by eric at