[#before_7] ['Definitions before section 7.] #include #include #include using namespace boost::metaparse; using exp_parser1 = build_parser; #include using exp_parser2 = build_parser>; #include using exp_parser3 = build_parser>>; #include #include using exp_parser4 = build_parser, token>, token>>; #include using int_token = token; using plus_token = token>; using exp_parser5 = build_parser>; #include #include #include template struct eval_plus : boost::mpl::plus< typename boost::mpl::at_c::type, typename boost::mpl::at_c::type > {}; #include using exp_parser6 = build_parser< transform< sequence, boost::mpl::quote1 > >; #include using exp_parser7 = build_parser< sequence< int_token, /* The first */ repeated> /* The "+ " elements */ > >; using temp_result = exp_parser7::apply::type; #include using vector_of_numbers = boost::mpl::vector< boost::mpl::int_<2>, boost::mpl::int_<5>, boost::mpl::int_<6> >; template struct sum_vector : boost::mpl::fold< Vector, boost::mpl::int_<0>, boost::mpl::lambda< boost::mpl::plus >::type > {}; template struct sum_items : boost::mpl::plus< Sum, typename boost::mpl::at_c::type > {}; using exp_parser8 = build_parser< sequence< int_token, /* parse the first */ transform< repeated>, /* parse the "+ " elements */ /* lambda expression summarising the "+ " elements using fold */ boost::mpl::lambda< /* The folding expression we have just created */ boost::mpl::fold< boost::mpl::_1, /* the argument of the lambda expression, the result */ /* of the repeated<...> parser */ boost::mpl::int_<0>, boost::mpl::quote2 > >::type > > >; using exp_parser9 = build_parser< transform< /* What we had so far */ sequence< int_token, transform< repeated>, boost::mpl::lambda< boost::mpl::fold< boost::mpl::_1, boost::mpl::int_<0>, boost::mpl::quote2 > >::type > >, boost::mpl::quote1 /* summarise the vector of numbers */ > >; #include using exp_parser10 = build_parser< transform< sequence< int_token, foldl< sequence, boost::mpl::int_<0>, boost::mpl::quote2 > >, boost::mpl::quote1> >; #include using exp_parser11 = build_parser< foldl_start_with_parser< sequence, /* apply this parser repeatedly */ int_token, /* use this parser to get the initial value */ boost::mpl::quote2 /* use this function to add a new value to the summary */ > >; using minus_token = token>; #include using exp_parser12 = build_parser< foldl_start_with_parser< sequence, int_token>, int_token, boost::mpl::quote2 > >; #include template struct eval_binary_op; template struct eval_binary_op : boost::mpl::plus::type {}; template struct eval_binary_op : boost::mpl::minus::type {}; template struct binary_op : eval_binary_op< S, boost::mpl::at_c::type::value, typename boost::mpl::at_c::type > {}; using exp_parser13 = build_parser< foldl_start_with_parser< sequence, int_token>, int_token, boost::mpl::quote2 > >;