Boost logo

Boost :

From: Eric Niebler (eric_at_[hidden])
Date: 2007-07-01 11:13:19

Eric Niebler wrote:
> dan marsden wrote:
>> As phoenix expressions have operator(), I'm already using an expression wrapper around all my proto expressions, so I presume that is where I would add any special member support?
> Yep. You could be to put all such members into the Phoenix expression
> wrapper and use a grammar to flag or disallow invalid uses. The members
> would just be Proto terminals, like "terminal<phoenix::tag::else_>::type
> const else_".

Oh wait, that's not quite what you want, because then if_[e1].else_[e2]
will chop off the if_ part of the tree. What you need instead is a
member like (untested):

template<typename Expr ...>
struct phoenix_expr
  : proto::extends<Expr ...>
    : else_(proto::make_expr<phoenix::tag::else_>(*this))

   // ...

      pheonix::tag::else_ // else is now an "operator"
    , phoenix_expr const
>::type const else_;

Then, if_/else_ statements would conform to the following grammar:


Eric Niebler
Boost Consulting

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