1 /*=============================================================================
2 Copyright (c) 2001-2003 Daniel Nuffer
3 http://spirit.sourceforge.net/
5 Distributed under the Boost Software License, Version 1.0. (See accompanying
6 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 =============================================================================*/
8 #ifndef BOOST_SPIRIT_FLUSH_MULTI_PASS_HPP
9 #define BOOST_SPIRIT_FLUSH_MULTI_PASS_HPP
11 ///////////////////////////////////////////////////////////////////////////////
12 #include <boost/spirit/home/classic/namespace.hpp>
13 #include <boost/spirit/home/classic/core.hpp>
14 #include <boost/spirit/home/classic/iterator/multi_pass.hpp>
16 ///////////////////////////////////////////////////////////////////////////////
17 namespace boost { namespace spirit {
19 BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
24 void flush_iterator(T &) {}
26 template <typename T1, typename T2, typename T3, typename T4>
27 void flush_iterator(BOOST_SPIRIT_CLASSIC_NS::multi_pass<
28 T1, T2, T3, T4, BOOST_SPIRIT_CLASSIC_NS::multi_pass_policies::std_deque> &i)
35 ///////////////////////////////////////////////////////////////////////////
37 // flush_multi_pass_parser
39 // The flush_multi_pass_parser flushes an underlying
40 // multi_pass_iterator during the normal parsing process. This may
41 // be used at certain points during the parsing process, when it is
42 // clear, that no backtracking is needed anymore and the input
43 // gathered so far may be discarded.
45 ///////////////////////////////////////////////////////////////////////////
46 class flush_multi_pass_parser
47 : public parser<flush_multi_pass_parser>
50 typedef flush_multi_pass_parser this_t;
52 template <typename ScannerT>
53 typename parser_result<this_t, ScannerT>::type
54 parse(ScannerT const& scan) const
56 impl::flush_iterator(scan.first);
57 return scan.empty_match();
61 ///////////////////////////////////////////////////////////////////////////
63 // predefined flush_multi_pass_p object
65 // This object should may used to flush a multi_pass_iterator along
66 // the way during the normal parsing process.
68 ///////////////////////////////////////////////////////////////////////////
70 flush_multi_pass_parser const
71 flush_multi_pass_p = flush_multi_pass_parser();
73 BOOST_SPIRIT_CLASSIC_NAMESPACE_END
75 }} // namespace BOOST_SPIRIT_CLASSIC_NS
77 #endif // BOOST_SPIRIT_FLUSH_MULTI_PASS_HPP