9.hpp 1.1 KB

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