#include #include #include #include namespace boost { namespace proto { struct external; // This specialization uses the Data parameter as a collection // of actions that can be indexed by the specified rule. template struct when { typedef typename Grammar::proto_grammar proto_grammar; template struct impl : Data::template when::template impl {}; template struct impl : Data::template when::template impl {}; }; }} namespace mpl = boost::mpl; namespace proto = boost::proto; using proto::_; struct int_terminal : proto::terminal {}; struct char_terminal : proto::terminal {}; struct my_grammar : proto::or_< proto::when< int_terminal, proto::external > , proto::when< char_terminal, proto::external > , proto::when< proto::plus< my_grammar, my_grammar > , proto::fold< _, int(), my_grammar > > > {}; struct print : proto::callable { typedef std::ostream & result_type; template result_type operator()(T t) const { return std::cout << t << ", "; } }; struct my_actions { template struct when; }; template<> struct my_actions::when : proto::call {}; template<> struct my_actions::when : proto::call()))> {}; int main() { proto::literal i(8), j(9); proto::literal a('a'), b('b'); my_actions act; my_grammar()(a + i, 0, act); std::cout.put('\n'); }