>> template <class T> >> struct make_vector >> { >> typedef boost::mpl::vector<T> type; >> }; >> >> struct B >> : proto::or_< >> proto::when < >> A, >> make_vector<A(proto::_)>()
>You could simply use mpl::vector1<A(proto::_)>() and not bother with >make_vector. Indeed. I tried with mpl::vector and it doesn't compile but vector1 does. Interesting. >If A is a grammar as implied above, you can simplify the function to: > > mpl::push_back<proto::_state, A>() > >The current element in the sequence will be operated on by default. This doesn't compile but I need to have a closer look, it could be another problem. A is actually a proto::switch on 2 cases, terminals and preincrement (for the moment). >Whoops! Your grammar doesn't handle expressions that aren't comma >expressions. Before passing an expr to a grammar, first try asserting >that it matches the grammar. This is done but not shown in the example. I use the grammar inside a function: ... foo(Expr) { BOOST_MPL_ASSERT((proto::matches<Expr, B>)); ... } >If it doesn't evaluating the grammar's >transform with the expr is a precondition violation. In this case, the >grammar check is ignored and the fold_tree is executed against whatever >expression you passed in. That will fold the tree on the top-most node >type; e.g. if it's tag::plus, you'll fold on plus. Ah yes I learned this one the hard way last night ;-) >> So I suppose that at least the first part of when is wrong. >> Any idea how to make it work? > >Depends on what you're trying to do. What should happen when you pass >something that isn't a comma expression? I call the grammar inside a function which asserts if proto::match rejects it. What I now have is a grammar which should parse a variable number of A expressions: ++_1 ++_1, ++_1 ++_1, ++_1, ++_1 etc. So I don't think comma<A,A> can possibly work, this would cover only (++_1,++_1) , right? Thanks, Christophe _______________________________________________ proto mailing list proto@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/proto