• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef BOOST_METAPARSE_GETTING_STARTED_9_HPP
2 #define BOOST_METAPARSE_GETTING_STARTED_9_HPP
3 
4 // Automatically generated header file
5 
6 // Definitions before section 8.2
7 #include "8_2.hpp"
8 
9 // Definitions of section 8.2
10 template <class S, class Item>
11  struct reverse_binary_op :
12    eval_binary_op<
13      typename boost::mpl::at_c<Item, 0>::type,
14      boost::mpl::at_c<Item, 1>::type::value,
15      S
16    >
17    {};
18 
19 #include <boost/metaparse/foldr_start_with_parser.hpp>
20 
21 using mult_exp3 =
22  foldr_start_with_parser<
23    sequence<int_token, one_of<times_token, divides_token>>, /* The parser applied repeatedly */
24    int_token, /* The parser parsing the last number */
25    boost::mpl::quote2<reverse_binary_op> /* The function called for every result */
26                                          /* of applying the above parser */
27  >;
28 
29 using exp_parser17 =
30  build_parser<
31    foldl_start_with_parser<
32      sequence<one_of<plus_token, minus_token>, mult_exp3>,
33      mult_exp3,
34      boost::mpl::quote2<binary_op>
35    >
36  >;
37 
38 // query:
39 //    exp_parser17::apply<BOOST_METAPARSE_STRING("8 / 4 / 2")>::type
40 
41 #endif
42 
43