Back to home page

EIC code displayed by LXR

 
 

    


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

0001 ///////////////////////////////////////////////////////////////////////////////
0002 // repeat_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_REPEAT_BEGIN_MATCHER_HPP_EAN_10_04_2005
0009 #define BOOST_XPRESSIVE_DETAIL_CORE_MATCHER_REPEAT_BEGIN_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/xpressive/detail/detail_fwd.hpp>
0017 #include <boost/xpressive/detail/core/quant_style.hpp>
0018 #include <boost/xpressive/detail/core/state.hpp>
0019 
0020 namespace boost { namespace xpressive { namespace detail
0021 {
0022 
0023     //
0024     // Note: here is the variable-width xpression quantifier. It always
0025     // matches at least once, so if the min is 0, it is the responsibility
0026     // of the parser to make it alternate with an epsilon matcher.
0027     //
0028 
0029     ///////////////////////////////////////////////////////////////////////////////
0030     // repeat_begin_matcher
0031     //
0032     struct repeat_begin_matcher
0033       : quant_style<quant_variable_width, unknown_width::value, false>
0034     {
0035         int mark_number_;
0036 
0037         repeat_begin_matcher(int mark_number)
0038           : mark_number_(mark_number)
0039         {
0040         }
0041 
0042         template<typename BidiIter, typename Next>
0043         bool match(match_state<BidiIter> &state, Next const &next) const
0044         {
0045             sub_match_impl<BidiIter> &br = state.sub_match(this->mark_number_);
0046 
0047             unsigned int old_repeat_count = br.repeat_count_;
0048             bool old_zero_width = br.zero_width_;
0049 
0050             br.repeat_count_ = 1;
0051             br.zero_width_ = false;
0052 
0053             // "push" next onto the stack, so it can be "popped" in
0054             // repeat_end_matcher and used to loop back.
0055             if(next.BOOST_NESTED_TEMPLATE push_match<Next>(state))
0056             {
0057                 return true;
0058             }
0059 
0060             br.repeat_count_ = old_repeat_count;
0061             br.zero_width_ = old_zero_width;
0062 
0063             return false;
0064         }
0065     };
0066 
0067 }}}
0068 
0069 #endif