
Kim Kuen Tang wrote:
Hi Dave and Eric,
i have written an grammar to do some transformations on an expression and would like to know your opinions.
If the grammar matches the pattern var_+a, then it should transform the tree to var_=(0-a)/1. So the resulting callable transform would be :
proto::when< //var_+a proto::plus<proto::terminal<placeholder>, proto::terminal<proto::_> > ,proto::_make_assign( proto::_left ,proto::_make_divides(proto::_make_minus(Zero ,proto::_right),One ) )
How should one implement the two macros Zero and One.
Try this: // default-constructs an int struct Zero : proto::make<int> {}; // initializes and int with a default-constructed mpl::int_<1> // object (which is convertible to an int with value of 1). struct One : proto::make<int(mpl::int_<1>())> {}; HTH, -- Eric Niebler BoostPro Computing http://www.boostpro.com