Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:53:49

0001 ///////////////////////////////////////////////////////////////////////////////
0002 // flow_control.hpp
0003 //
0004 //  Copyright 2008 Eric Niebler. Distributed under the Boost
0005 //  Software License, Version 1.0. (See accompanying file
0006 //  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0007 
0008 #ifndef BOOST_XPRESSIVE_DETAIL_CORE_FLOW_CONTROL_HPP_EAN_10_04_2005
0009 #define BOOST_XPRESSIVE_DETAIL_CORE_FLOW_CONTROL_HPP_EAN_10_04_2005
0010 
0011 // MS compatible compilers support #pragma once
0012 #if defined(_MSC_VER)
0013 # pragma once
0014 #endif
0015 
0016 #include <boost/xpressive/detail/detail_fwd.hpp>
0017 #include <boost/xpressive/detail/core/regex_impl.hpp>
0018 #include <boost/xpressive/detail/core/state.hpp>
0019 #include <boost/xpressive/detail/utility/ignore_unused.hpp>
0020 
0021 namespace boost { namespace xpressive { namespace detail
0022 {
0023 
0024 ///////////////////////////////////////////////////////////////////////////////
0025 // push_context_match
0026 //
0027 template<typename BidiIter>
0028 inline bool push_context_match
0029 (
0030     regex_impl<BidiIter> const &impl
0031   , match_state<BidiIter> &state
0032   , matchable<BidiIter> const &next
0033 )
0034 {
0035     // avoid infinite recursion
0036     // BUGBUG this only catches direct infinite recursion, like sregex::compile("(?R)"), but
0037     // not indirect infinite recursion where two rules invoke each other recursively.
0038     if(state.is_active_regex(impl) && state.cur_ == state.sub_match(0).begin_)
0039     {
0040         return next.match(state);
0041     }
0042 
0043     // save state
0044     match_context<BidiIter> context = state.push_context(impl, next, context);
0045     detail::ignore_unused(context);
0046 
0047     // match the nested regex and uninitialize the match context
0048     // (reclaims the sub_match objects if necessary)
0049     return state.pop_context(impl, impl.xpr_->match(state));
0050 }
0051 
0052 ///////////////////////////////////////////////////////////////////////////////
0053 // pop_context_match
0054 //
0055 template<typename BidiIter>
0056 inline bool pop_context_match(match_state<BidiIter> &state)
0057 {
0058     // save state
0059     // BUGBUG nested regex could have changed state.traits_
0060     match_context<BidiIter> &context(*state.context_.prev_context_);
0061     state.swap_context(context);
0062 
0063     // Finished matching the nested regex; now match the rest of the enclosing regex
0064     bool success = context.next_ptr_->match(state);
0065 
0066     // restore state
0067     state.swap_context(context);
0068     return success;
0069 }
0070 
0071 }}} // namespace boost::xpressive::detail
0072 
0073 #endif
0074