eoi.hpp 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*=============================================================================
  2. Copyright (c) 2001-2011 Hartmut Kaiser
  3. Copyright (c) 2001-2011 Joel de Guzman
  4. Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. ==============================================================================*/
  7. #if !defined(BOOST_SPIRIT_EOI_APRIL_18_2008_0751PM)
  8. #define BOOST_SPIRIT_EOI_APRIL_18_2008_0751PM
  9. #if defined(_MSC_VER)
  10. #pragma once
  11. #endif
  12. #include <boost/mpl/bool.hpp>
  13. #include <boost/spirit/home/qi/domain.hpp>
  14. #include <boost/spirit/home/qi/parser.hpp>
  15. #include <boost/spirit/home/qi/meta_compiler.hpp>
  16. #include <boost/spirit/home/qi/skip_over.hpp>
  17. #include <boost/spirit/home/support/common_terminals.hpp>
  18. namespace boost { namespace spirit
  19. {
  20. ///////////////////////////////////////////////////////////////////////////
  21. // Enablers
  22. ///////////////////////////////////////////////////////////////////////////
  23. template <>
  24. struct use_terminal<qi::domain, tag::eoi> // enables eoi
  25. : mpl::true_ {};
  26. }}
  27. namespace boost { namespace spirit { namespace qi
  28. {
  29. #ifndef BOOST_SPIRIT_NO_PREDEFINED_TERMINALS
  30. using spirit::eoi;
  31. #endif
  32. using spirit::eoi_type;
  33. struct eoi_parser : primitive_parser<eoi_parser>
  34. {
  35. template <typename Context, typename Iterator>
  36. struct attribute
  37. {
  38. typedef unused_type type;
  39. };
  40. template <typename Iterator, typename Context
  41. , typename Skipper, typename Attribute>
  42. bool parse(Iterator& first, Iterator const& last
  43. , Context& /*context*/, Skipper const& skipper
  44. , Attribute& /*attr*/) const
  45. {
  46. qi::skip_over(first, last, skipper);
  47. return first == last;
  48. }
  49. template <typename Context>
  50. info what(Context& /*context*/) const
  51. {
  52. return info("eoi");
  53. }
  54. };
  55. ///////////////////////////////////////////////////////////////////////////
  56. // Parser generators: make_xxx function (objects)
  57. ///////////////////////////////////////////////////////////////////////////
  58. template <typename Modifiers>
  59. struct make_primitive<tag::eoi, Modifiers>
  60. {
  61. typedef eoi_parser result_type;
  62. result_type operator()(unused_type, unused_type) const
  63. {
  64. return result_type();
  65. }
  66. };
  67. }}}
  68. #endif