[#before_11_3_2] ['Definitions before section 11.3.2.] #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 > >; #include template struct eval_binary_op : boost::mpl::times::type {}; using times_token = token>; using exp_parser14 = build_parser< foldl_start_with_parser< sequence, int_token>, int_token, boost::mpl::quote2 > >; using mult_exp1 = foldl_start_with_parser, int_token, boost::mpl::quote2>; using exp_parser15 = build_parser< foldl_start_with_parser< sequence, mult_exp1>, mult_exp1, boost::mpl::quote2 > >; #include template struct eval_binary_op : boost::mpl::divides::type {}; using divides_token = token>; using mult_exp2 = foldl_start_with_parser< sequence, int_token>, int_token, boost::mpl::quote2 >; using exp_parser16 = build_parser< foldl_start_with_parser< sequence, mult_exp2>, mult_exp2, boost::mpl::quote2 > >; template struct reverse_binary_op : eval_binary_op< typename boost::mpl::at_c::type, boost::mpl::at_c::type::value, S > {}; #include using mult_exp3 = foldr_start_with_parser< sequence>, /* The parser applied repeatedly */ int_token, /* The parser parsing the last number */ boost::mpl::quote2 /* The function called for every result */ /* of applying the above parser */ >; using exp_parser17 = build_parser< foldl_start_with_parser< sequence, mult_exp3>, mult_exp3, boost::mpl::quote2 > >; #include using unary_exp1 = foldr_start_with_parser< minus_token, int_token, boost::mpl::lambda>::type >; using mult_exp4 = foldl_start_with_parser< sequence, unary_exp1>, unary_exp1, boost::mpl::quote2 >; using exp_parser18 = build_parser< foldl_start_with_parser< sequence, mult_exp4>, mult_exp4, boost::mpl::quote2 > >; using lparen_token = token>; using rparen_token = token>; using plus_exp1 = foldl_start_with_parser< sequence, mult_exp4>, mult_exp4, boost::mpl::quote2 >; using paren_exp1 = sequence; #include using paren_exp2 = middle_of; using primary_exp1 = one_of; struct plus_exp2; using paren_exp3 = middle_of; using primary_exp2 = one_of; using unary_exp2 = foldr_start_with_parser< minus_token, primary_exp2, boost::mpl::lambda>::type >; using mult_exp5 = foldl_start_with_parser< sequence, unary_exp2>, unary_exp2, boost::mpl::quote2 >; struct plus_exp2 : foldl_start_with_parser< sequence, mult_exp5>, mult_exp5, boost::mpl::quote2 > {}; using exp_parser19 = build_parser; #include BOOST_METAPARSE_DEFINE_ERROR(missing_primary_expression, "Missing primary expression"); struct plus_exp3; using paren_exp4 = middle_of; #include using primary_exp3 = one_of>; using unary_exp3 = foldr_start_with_parser< minus_token, primary_exp3, boost::mpl::lambda>::type >; using mult_exp6 = foldl_start_with_parser< sequence, unary_exp3>, unary_exp3, boost::mpl::quote2 >; struct plus_exp3 : foldl_start_with_parser< sequence, mult_exp6>, mult_exp6, boost::mpl::quote2 > {}; using exp_parser20 = build_parser; #include #include struct plus_exp4 : first_of< foldl_start_with_parser< sequence, mult_exp6>, mult_exp6, boost::mpl::quote2 >, fail_at_first_char_expected< sequence, mult_exp6> > > {}; using exp_parser21 = build_parser; #include struct plus_exp5 : foldl_reject_incomplete_start_with_parser< sequence, mult_exp6>, mult_exp6, boost::mpl::quote2 > {}; using exp_parser22 = build_parser;