flush_multi_pass.hpp 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. // Copyright (c) 2001-2011 Hartmut Kaiser
  2. //
  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. #if !defined(BOOST_SPIRIT_REPOSITORY_QI_FLUSH_MULTI_PASS_JUL_10_2009_0535PM)
  6. #define BOOST_SPIRIT_REPOSITORY_QI_FLUSH_MULTI_PASS_JUL_10_2009_0535PM
  7. #if defined(_MSC_VER)
  8. #pragma once
  9. #endif
  10. #include <boost/spirit/home/qi/domain.hpp>
  11. #include <boost/spirit/home/qi/meta_compiler.hpp>
  12. #include <boost/spirit/home/support/common_terminals.hpp>
  13. #include <boost/spirit/home/support/info.hpp>
  14. #include <boost/spirit/home/support/unused.hpp>
  15. #include <boost/spirit/home/support/attributes.hpp>
  16. #include <boost/spirit/home/support/multi_pass.hpp>
  17. #include <boost/spirit/repository/home/support/flush_multi_pass.hpp>
  18. ///////////////////////////////////////////////////////////////////////////////
  19. namespace boost { namespace spirit
  20. {
  21. ///////////////////////////////////////////////////////////////////////////
  22. // Enablers
  23. ///////////////////////////////////////////////////////////////////////////
  24. // enables flush_multi_pass
  25. template <>
  26. struct use_terminal<qi::domain, repository::tag::flush_multi_pass>
  27. : mpl::true_ {};
  28. }}
  29. ///////////////////////////////////////////////////////////////////////////////
  30. namespace boost { namespace spirit { namespace repository { namespace qi
  31. {
  32. #ifndef BOOST_SPIRIT_NO_PREDEFINED_TERMINALS
  33. using repository::flush_multi_pass;
  34. #endif
  35. using repository::flush_multi_pass_type;
  36. ///////////////////////////////////////////////////////////////////////////
  37. // for a flush_multi_pass_parser generated parser
  38. struct flush_multi_pass_parser
  39. : spirit::qi::primitive_parser<flush_multi_pass_parser>
  40. {
  41. template <typename Context, typename Unused>
  42. struct attribute
  43. {
  44. typedef unused_type type;
  45. };
  46. template <typename Iterator, typename Context
  47. , typename Skipper, typename Attribute>
  48. bool parse(Iterator& first, Iterator const& last
  49. , Context& context, Skipper const& skipper
  50. , Attribute& attr) const
  51. {
  52. spirit::traits::clear_queue(first, traits::clear_mode::clear_always);
  53. return true;
  54. }
  55. template <typename Context>
  56. info what(Context const& ctx) const
  57. {
  58. return info("flush_multi_pass");
  59. }
  60. };
  61. }}}}
  62. ///////////////////////////////////////////////////////////////////////////////
  63. namespace boost { namespace spirit { namespace qi
  64. {
  65. ///////////////////////////////////////////////////////////////////////////
  66. // Parser generators: make_xxx function (objects)
  67. ///////////////////////////////////////////////////////////////////////////
  68. template <typename Modifiers>
  69. struct make_primitive<repository::tag::flush_multi_pass, Modifiers>
  70. {
  71. typedef repository::qi::flush_multi_pass_parser result_type;
  72. result_type operator()(unused_type, unused_type) const
  73. {
  74. return result_type();
  75. }
  76. };
  77. }}}
  78. #endif