]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | /*============================================================================= |
2 | Copyright (c) 2001-2003 Daniel Nuffer | |
3 | http://spirit.sourceforge.net/ | |
4 | ||
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 | |
10 | ||
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> | |
15 | ||
16 | /////////////////////////////////////////////////////////////////////////////// | |
17 | namespace boost { namespace spirit { | |
18 | ||
19 | BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN | |
20 | ||
21 | namespace impl { | |
22 | ||
23 | template <typename T> | |
24 | void flush_iterator(T &) {} | |
25 | ||
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) | |
29 | { | |
30 | i.clear_queue(); | |
31 | } | |
32 | ||
33 | } // namespace impl | |
34 | ||
35 | /////////////////////////////////////////////////////////////////////////// | |
36 | // | |
37 | // flush_multi_pass_parser | |
38 | // | |
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. | |
44 | // | |
45 | /////////////////////////////////////////////////////////////////////////// | |
46 | class flush_multi_pass_parser | |
47 | : public parser<flush_multi_pass_parser> | |
48 | { | |
49 | public: | |
50 | typedef flush_multi_pass_parser this_t; | |
51 | ||
52 | template <typename ScannerT> | |
53 | typename parser_result<this_t, ScannerT>::type | |
54 | parse(ScannerT const& scan) const | |
55 | { | |
56 | impl::flush_iterator(scan.first); | |
57 | return scan.empty_match(); | |
58 | } | |
59 | }; | |
60 | ||
61 | /////////////////////////////////////////////////////////////////////////// | |
62 | // | |
63 | // predefined flush_multi_pass_p object | |
64 | // | |
65 | // This object should may used to flush a multi_pass_iterator along | |
66 | // the way during the normal parsing process. | |
67 | // | |
68 | /////////////////////////////////////////////////////////////////////////// | |
69 | ||
70 | flush_multi_pass_parser const | |
71 | flush_multi_pass_p = flush_multi_pass_parser(); | |
72 | ||
73 | BOOST_SPIRIT_CLASSIC_NAMESPACE_END | |
74 | ||
75 | }} // namespace BOOST_SPIRIT_CLASSIC_NS | |
76 | ||
77 | #endif // BOOST_SPIRIT_FLUSH_MULTI_PASS_HPP |