1 ///////////////////////////////////////////////////////////////////////////////
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_END_MATCHER_HPP_EAN_10_04_2005
9 #define BOOST_XPRESSIVE_DETAIL_CORE_MATCHER_END_MATCHER_HPP_EAN_10_04_2005
11 // MS compatible compilers support #pragma once
16 #include <boost/assert.hpp>
17 #include <boost/xpressive/detail/detail_fwd.hpp>
18 #include <boost/xpressive/detail/core/quant_style.hpp>
19 #include <boost/xpressive/detail/core/state.hpp>
20 #include <boost/xpressive/detail/core/sub_match_impl.hpp>
21 #include <boost/xpressive/detail/core/flow_control.hpp>
23 namespace boost { namespace xpressive { namespace detail
26 ///////////////////////////////////////////////////////////////////////////////
30 : quant_style_assertion
32 template<typename BidiIter, typename Next>
33 static bool match(match_state<BidiIter> &state, Next const &)
35 BidiIter const tmp = state.cur_;
36 sub_match_impl<BidiIter> &s0 = state.sub_match(0);
37 BOOST_ASSERT(!s0.matched);
39 // SPECIAL: if there is a match context on the context stack, then
40 // this pattern has been nested within another. pop that context and
41 // continue executing.
42 if(0 != state.context_.prev_context_)
44 if(!pop_context_match(state))
49 // record the end of sub-match zero
56 else if((state.flags_.match_all_ && !state.eos()) ||
57 (state.flags_.match_not_null_ && state.cur_ == s0.begin_))
62 // record the end of sub-match zero
67 // Now execute any actions that have been queued
68 for(actionable const *actor = state.action_list_.next; 0 != actor; actor = actor->next)
70 actor->execute(state.action_args_);
77 ///////////////////////////////////////////////////////////////////////////////
78 // independent_end_matcher
80 struct independent_end_matcher
81 : quant_style_assertion
83 template<typename BidiIter, typename Next>
84 bool match(match_state<BidiIter> &state, Next const &) const
86 // Now execute any actions that have been queued
87 for(actionable const *actor = state.action_list_.next; 0 != actor; actor = actor->next)
89 actor->execute(state.action_args_);