
Eric Niebler <eric@boost-consulting.com> writes:
For instance, given the pattern:
proto::terminal< number<bounds<run_time,_>,_,_,_,_,_> >
how can I refer in the rhs of a transform to:
What do you mean by "rhs"?
if you see a transform as pattern -> transformed tree, then pattern would be the lhs and the transformed tree would be the rhs.
a) the entire pattern being matched (e.g. terminal<> or number<>)
Transforms are always of the following form:
template<typename Grammar> struct some_transform : Grammar { template<typename Expr, typename State, typename Visitor> struct apply { typedef ... type; };
template<typename Expr, typename State, typename Visitor> static typename apply<Expr, State, Visitor>::type call(Expr const &expr, State const &state, Visitor &visitor) { return ...; } };
Oh. Yes, makes sense. Now I got it. What I was trying was to use the default transform proto::always<pattern, replacement> hoping that somehow I would have gotten mpl::placeholders bound inside replacement.
There are no mpl placeholders here, and the placeholders are not positional like that. You can't say, find me what matched the Nth occurance of proto::_. You only get the whole expression that matched.
Would have been nice, though...
This is blocking me at the moment, so if anybody has suggestions, they would be very much appreciated.
HTH,
Hugely. Obviously I'll find problems as soon as I start implementing it, but I think now I've got it. Thanks again, Maurizio