Boost logo

Boost Users :

Subject: Re: [Boost-users] [Proto] Detecting series of operator in grammar
From: Eric Niebler (eric_at_[hidden])
Date: 2008-12-03 13:47:29


Joel Falcou wrote:
> Eric Niebler a écrit :
>>
>> You use proto::functional::flatten to turn the binary + expression
>> tree into a flat Fusion sequence, and then you use
>> proto::functional::unpack_expr to turn the Fusion sequence into an
>> expression node with any tag you want. See below:
> I was roaming around flatten so guess I only missed the as_vector trick.
> I guess this means that this "n-ary" plus expression node can be then
> latter be matched by another grammar
> defined like (simple version ofc) :
>
> struct some_grammar
> : nary_expr<plus,vararg<_> > {};

Yep.

I forgot to mention that you need to be aware of BOOST_PROTO_MAX_ARITY
when unpacking sequences into expression nodes.

-- 
Eric Niebler
BoostPro Computing
http://www.boostpro.com

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net