1
/*=============================================================================
3
Copyright (c) 2001-2003 Daniel Nuffer
4
http://spirit.sourceforge.net/
6
Permission to copy, use, modify, sell and distribute this software is
7
granted provided this copyright notice appears in all copies. This
8
software is provided "as is" without express or implied warranty, and
9
with no claim as to its suitability for any purpose.
10
=============================================================================*/
11
#ifndef BOOST_SPIRIT_FLUSH_MULTI_PASS_HPP
12
#define BOOST_SPIRIT_FLUSH_MULTI_PASS_HPP
14
///////////////////////////////////////////////////////////////////////////////
15
#include "boost/spirit/core.hpp"
16
#include "boost/spirit/iterator/multi_pass.hpp"
18
///////////////////////////////////////////////////////////////////////////////
19
namespace boost { namespace spirit {
24
void flush_iterator(T &) {}
26
template <typename T1, typename T2, typename T3, typename T4>
27
void flush_iterator(boost::spirit::multi_pass<
28
T1, T2, T3, T4, boost::spirit::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
}} // namespace boost::spirit
75
#endif // BOOST_SPIRIT_FLUSH_MULTI_PASS_HPP