I defined a context for my grammar that is tuned to input types, something like the snippet below. I'm missing types where ???? there is.
Before starting to write recursive templates to understand them, is there anything in the proto?
template<typename PlaceholderTypes> // mpl vector of placeholder types class calculator_context : public proto::callable_context< calculator_context<PlaceholderTypes>, proto::null_context const > { public: template<typename T> struct MakePtrType { typedef boost::shared_ptr<T> type; }; // Values to replace the placeholders typedef typename boost::mpl::transform<PlaceholderTypes,MakePtrType<boost::mpl::_1> >::type inputTypes; typename boost::fusion::result_of::as_vector<typename inputTypes::type>::type args; // Handle the placeholders: template<int I> typename boost::shared_ptr<boost::mpl::at<PlaceholderTypes,boost::mpl::int_<I> > >::type operator()(proto::tag::terminal, placeholder<I>) { typedef typename boost::mpl::at<PlaceholderTypes,boost::mpl::int_<I> >::type param_type; boost::shared_ptr<param_type> p = boost::fusion::at_c<I>(this->args); return p; } // Define the result type of the calculator. // (This makes the calculator_context "callable".) typedef ??????? result_type; template <typename Expr1, typename Expr2> result_type operator()(proto::tag::plus, const Expr1& lhs, const Expr2& rhs) { typedef ??? lhs_result_type; // result of proto::eval(lhs, ctx); .... } };
source share