1
///////////////////////////////////////////////////////////////////////////////
2
// repeat_end_matcher.hpp
4
// Copyright 2008 Eric Niebler. Distributed under the Boost
5
// Software License, Version 1.0. (See accompanying file
6
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
8
#ifndef BOOST_XPRESSIVE_DETAIL_CORE_MATCHER_REPEAT_BEGIN_MATCHER_HPP_EAN_10_04_2005
9
#define BOOST_XPRESSIVE_DETAIL_CORE_MATCHER_REPEAT_BEGIN_MATCHER_HPP_EAN_10_04_2005
11
// MS compatible compilers support #pragma once
12
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
16
#include <boost/xpressive/detail/detail_fwd.hpp>
17
#include <boost/xpressive/detail/core/quant_style.hpp>
18
#include <boost/xpressive/detail/core/state.hpp>
20
namespace boost { namespace xpressive { namespace detail
24
// Note: here is the variable-width xpression quantifier. It always
25
// matches at least once, so if the min is 0, it is the responsibility
26
// of the parser to make it alternate with an epsilon matcher.
29
///////////////////////////////////////////////////////////////////////////////
30
// repeat_begin_matcher
32
struct repeat_begin_matcher
33
: quant_style<quant_variable_width, unknown_width::value, false>
37
repeat_begin_matcher(int mark_number)
38
: mark_number_(mark_number)
42
template<typename BidiIter, typename Next>
43
bool match(match_state<BidiIter> &state, Next const &next) const
45
sub_match_impl<BidiIter> &br = state.sub_match(this->mark_number_);
47
unsigned int old_repeat_count = br.repeat_count_;
48
bool old_zero_width = br.zero_width_;
51
br.zero_width_ = false;
53
// "push" next onto the stack, so it can be "popped" in
54
// repeat_end_matcher and used to loop back.
55
if(next.BOOST_NESTED_TEMPLATE push_match<Next>(state))
60
br.repeat_count_ = old_repeat_count;
61
br.zero_width_ = old_zero_width;