omit.hpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*=============================================================================
  2. Copyright (c) 2001-2014 Joel de Guzman
  3. Distributed under the Boost Software License, Version 1.0. (See accompanying
  4. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. =============================================================================*/
  6. #if !defined(BOOST_SPIRIT_X3_OMIT_MARCH_24_2007_0802AM)
  7. #define BOOST_SPIRIT_X3_OMIT_MARCH_24_2007_0802AM
  8. #include <boost/spirit/home/x3/support/unused.hpp>
  9. #include <boost/spirit/home/x3/core/parser.hpp>
  10. namespace boost { namespace spirit { namespace x3
  11. {
  12. ///////////////////////////////////////////////////////////////////////////
  13. // omit_directive forces the attribute of subject parser
  14. // to be unused_type
  15. ///////////////////////////////////////////////////////////////////////////
  16. template <typename Subject>
  17. struct omit_directive : unary_parser<Subject, omit_directive<Subject>>
  18. {
  19. typedef unary_parser<Subject, omit_directive<Subject> > base_type;
  20. typedef unused_type attribute_type;
  21. static bool const has_attribute = false;
  22. typedef Subject subject_type;
  23. omit_directive(Subject const& subject)
  24. : base_type(subject) {}
  25. template <typename Iterator, typename Context, typename RContext>
  26. bool parse(Iterator& first, Iterator const& last
  27. , Context const& context, RContext& rcontext, unused_type) const
  28. {
  29. return this->subject.parse(first, last, context, rcontext, unused);
  30. }
  31. };
  32. struct omit_gen
  33. {
  34. template <typename Subject>
  35. omit_directive<typename extension::as_parser<Subject>::value_type>
  36. operator[](Subject const& subject) const
  37. {
  38. return { as_parser(subject) };
  39. }
  40. };
  41. auto const omit = omit_gen{};
  42. }}}
  43. #endif