char_parser.hpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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_CHAR_PARSER_APR_16_2006_0906AM)
  7. #define BOOST_SPIRIT_X3_CHAR_PARSER_APR_16_2006_0906AM
  8. #include <boost/spirit/home/x3/core/parser.hpp>
  9. #include <boost/spirit/home/x3/core/skip_over.hpp>
  10. #include <boost/spirit/home/x3/support/traits/move_to.hpp>
  11. #include <boost/spirit/home/x3/support/no_case.hpp>
  12. namespace boost { namespace spirit { namespace x3
  13. {
  14. ///////////////////////////////////////////////////////////////////////////
  15. // The base char_parser
  16. ///////////////////////////////////////////////////////////////////////////
  17. template <typename Derived>
  18. struct char_parser : parser<Derived>
  19. {
  20. template <typename Iterator, typename Context, typename Attribute>
  21. bool parse(
  22. Iterator& first, Iterator const& last
  23. , Context const& context, unused_type, Attribute& attr) const
  24. {
  25. x3::skip_over(first, last, context);
  26. if (first != last && this->derived().test(*first, context))
  27. {
  28. x3::traits::move_to(*first, attr);
  29. ++first;
  30. return true;
  31. }
  32. return false;
  33. }
  34. };
  35. }}}
  36. #endif