apply_parser.hpp 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #ifndef BOOST_METAPARSE_V1_IMPL_APPLY_PARSER_HPP
  2. #define BOOST_METAPARSE_V1_IMPL_APPLY_PARSER_HPP
  3. // Copyright Abel Sinkovics (abel@sinkovics.hu) 2013.
  4. // Distributed under the Boost Software License, Version 1.0.
  5. // (See accompanying file LICENSE_1_0.txt or copy at
  6. // http://www.boost.org/LICENSE_1_0.txt)
  7. #include <boost/metaparse/v1/unless_error.hpp>
  8. #include <boost/metaparse/v1/get_result.hpp>
  9. #include <boost/metaparse/v1/get_remaining.hpp>
  10. #include <boost/metaparse/v1/get_position.hpp>
  11. #include <boost/metaparse/v1/transform.hpp>
  12. #include <boost/mpl/push_back.hpp>
  13. namespace boost
  14. {
  15. namespace metaparse
  16. {
  17. namespace v1
  18. {
  19. namespace impl
  20. {
  21. struct apply_parser
  22. {
  23. private:
  24. template <class ListToAppend>
  25. struct do_append
  26. {
  27. template <class Item>
  28. struct apply : boost::mpl::push_back<ListToAppend, Item> {};
  29. };
  30. template <class Accum, class S, class Pos, class Parser>
  31. struct apply_unchecked :
  32. transform<Parser,do_append<typename Accum::type> >::template apply<
  33. typename S::type,
  34. typename Pos::type
  35. >
  36. {};
  37. public:
  38. template <class State, class Parser>
  39. struct apply :
  40. unless_error<
  41. State,
  42. apply_unchecked<
  43. get_result<State>,
  44. get_remaining<State>,
  45. get_position<State>,
  46. Parser
  47. >
  48. >
  49. {};
  50. };
  51. }
  52. }
  53. }
  54. }
  55. #endif