Back to home page

EIC code displayed by LXR

 
 

    


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

0001 ///////////////////////////////////////////////////////////////////////////////
0002 // end_matcher.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_MATCHER_END_MATCHER_HPP_EAN_10_04_2005
0009 #define BOOST_XPRESSIVE_DETAIL_CORE_MATCHER_END_MATCHER_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/assert.hpp>
0017 #include <boost/xpressive/detail/detail_fwd.hpp>
0018 #include <boost/xpressive/detail/core/quant_style.hpp>
0019 #include <boost/xpressive/detail/core/state.hpp>
0020 #include <boost/xpressive/detail/core/sub_match_impl.hpp>
0021 #include <boost/xpressive/detail/core/flow_control.hpp>
0022 
0023 namespace boost { namespace xpressive { namespace detail
0024 {
0025 
0026     ///////////////////////////////////////////////////////////////////////////////
0027     // end_matcher
0028     //
0029     struct end_matcher
0030       : quant_style_assertion
0031     {
0032         template<typename BidiIter, typename Next>
0033         static bool match(match_state<BidiIter> &state, Next const &)
0034         {
0035             BidiIter const tmp = state.cur_;
0036             sub_match_impl<BidiIter> &s0 = state.sub_match(0);
0037             BOOST_ASSERT(!s0.matched);
0038 
0039             // SPECIAL: if there is a match context on the context stack, then
0040             // this pattern has been nested within another. pop that context and
0041             // continue executing.
0042             if(0 != state.context_.prev_context_)
0043             {
0044                 if(!pop_context_match(state))
0045                 {
0046                     return false;
0047                 }
0048 
0049                 // record the end of sub-match zero
0050                 s0.first = s0.begin_;
0051                 s0.second = tmp;
0052                 s0.matched = true;
0053 
0054                 return true;
0055             }
0056             else if((state.flags_.match_all_ && !state.eos()) ||
0057                     (state.flags_.match_not_null_ && state.cur_ == s0.begin_))
0058             {
0059                 return false;
0060             }
0061 
0062             // record the end of sub-match zero
0063             s0.first = s0.begin_;
0064             s0.second = tmp;
0065             s0.matched = true;
0066 
0067             // Now execute any actions that have been queued
0068             for(actionable const *actor = state.action_list_.next; 0 != actor; actor = actor->next)
0069             {
0070                 actor->execute(state.action_args_);
0071             }
0072 
0073             return true;
0074         }
0075     };
0076 
0077     ///////////////////////////////////////////////////////////////////////////////
0078     // independent_end_matcher
0079     //
0080     struct independent_end_matcher
0081       : quant_style_assertion
0082     {
0083         template<typename BidiIter, typename Next>
0084         bool match(match_state<BidiIter> &state, Next const &) const
0085         {
0086             // Now execute any actions that have been queued
0087             for(actionable const *actor = state.action_list_.next; 0 != actor; actor = actor->next)
0088             {
0089                 actor->execute(state.action_args_);
0090             }
0091 
0092             return true;
0093         }
0094     };
0095 
0096 }}}
0097 
0098 #endif