コード例 #1
0
ファイル: literal_matcher.hpp プロジェクト: AsherBond/PDAL
        bool match(match_state<BidiIter> &state, Next const &next) const
        {
            if(state.eos() || Not::value ==
                (detail::translate(*state.cur_, traits_cast<Traits>(state), icase_type()) == this->ch_))
            {
                return false;
            }

            ++state.cur_;
            if(next.match(state))
            {
                return true;
            }

            --state.cur_;
            return false;
        }
コード例 #2
0
        bool match(state_type<BidiIter> &state, Next const &next) const
        {
            if(state.eos() || this->not_ == traits_cast<Traits>(state).isctype(
                *state.cur_, this->mask_))
            {
                return false;
            }

            ++state.cur_;
            if(next.match(state))
            {
                return true;
            }

            --state.cur_;
            return false;
        }
コード例 #3
0
ファイル: range_matcher.hpp プロジェクト: rogerclark/grumble
        bool match(match_state<BidiIter> &state, Next const &next) const
        {
            if(state.eos() || this->not_ ==
                this->in_range(traits_cast<Traits>(state), *state.cur_, icase_type()))
            {
                return false;
            }

            ++state.cur_;
            if(next.match(state))
            {
                return true;
            }

            --state.cur_;
            return false;
        }
コード例 #4
0
 bool match(match_state<BidiIter> &state, Next const &next) const
 {
     BidiIter tmp = state.cur_;
     char_translate<Traits, ICase::value> trans(traits_cast<Traits>(state));
     result_type const &result = this->sym_(state.cur_, state.end_, trans);
     if(result)
     {
         void const *old_slot = state.attr_context_.attr_slots_[this->slot_];
         state.attr_context_.attr_slots_[this->slot_] = &*result;
         if(next.match(state))
         {
             return true;
         }
         state.attr_context_.attr_slots_[this->slot_] = old_slot;
     }
     state.cur_ = tmp;
     return false;
 }
コード例 #5
0
        bool match_(match_state<BidiIter> &state, Next const &next, greedy_slow_tag) const
        {
            int const diff = -static_cast<int>(Xpr::width == unknown_width::value ? this->width_ : Xpr::width);
            unsigned int matches = 0;
            BidiIter const tmp = state.cur_;

            // greedily match as much as we can
            while(matches < this->max_ && this->xpr_.match(state))
            {
                ++matches;
            }

            // If this repeater is at the front of the pattern, note
            // how much of the input we consumed so that a repeated search
            // doesn't have to cover the same ground again.
            if(this->leading_)
            {
                state.next_search_ = (matches && matches < this->max_)
                                   ? state.cur_
                                   : (tmp == state.end_) ? tmp : boost::next(tmp);
            }

            if(this->min_ > matches)
            {
                state.cur_ = tmp;
                return false;
            }

            // try matching the rest of the pattern, and back off if necessary
            for(; ; --matches, std::advance(state.cur_, diff))
            {
                if(next.match(state))
                {
                    return true;
                }
                else if(this->min_ == matches)
                {
                    state.cur_ = tmp;
                    return false;
                }
            }
        }
コード例 #6
0
ファイル: string_matcher.hpp プロジェクト: AsherBond/PDAL
        bool match(match_state<BidiIter> &state, Next const &next) const
        {
            BidiIter const tmp = state.cur_;
            char_type const *begin = detail::data_begin(this->str_);
            for(; begin != this->end_; ++begin, ++state.cur_)
            {
                if(state.eos() ||
                    (detail::translate(*state.cur_, traits_cast<Traits>(state), icase_type()) != *begin))
                {
                    state.cur_ = tmp;
                    return false;
                }
            }

            if(next.match(state))
            {
                return true;
            }

            state.cur_ = tmp;
            return false;
        }
コード例 #7
0
        bool match_(match_state<BidiIter> &state, Next const &next, greedy_fast_tag) const
        {
            BidiIter const tmp = state.cur_;
            std::size_t const diff_to_end = static_cast<std::size_t>(state.end_ - tmp);

            // is there enough room?
            if(this->min_ > diff_to_end)
            {
                if(this->leading_)
                {
                    state.next_search_ = (tmp == state.end_) ? tmp : boost::next(tmp);
                }
                return false;
            }

            BidiIter const min_iter = tmp + this->min_;
            state.cur_ += (std::min)((std::size_t)this->max_, diff_to_end);

            if(this->leading_)
            {
                state.next_search_ = (diff_to_end && diff_to_end < this->max_)
                                   ? state.cur_
                                   : (tmp == state.end_) ? tmp : boost::next(tmp);
            }

            for(;; --state.cur_)
            {
                if(next.match(state))
                {
                    return true;
                }
                else if(min_iter == state.cur_)
                {
                    state.cur_ = tmp;
                    return false;
                }
            }
        }
コード例 #8
0
        bool match(state_type<BidiIter> &state, Next const &next) const
        {
            sub_match_impl<BidiIter> &br = state.sub_match(this->mark_number_);

            BidiIter old_first = br.first;
            BidiIter old_second = br.second;
            bool old_matched = br.matched;

            br.first = br.begin_;
            br.second = state.cur_;
            br.matched = true;

            if(next.match(state))
            {
                return true;
            }

            br.first = old_first;
            br.second = old_second;
            br.matched = old_matched;

            return false;
        }
コード例 #9
0
 bool match_(match_state<BidiIter> &state, Next const &next, mpl::false_) const // Non-greedy
 {
     return next.match(state)
         || this->xpr_.BOOST_NESTED_TEMPLATE push_match<Next>(state);
 }
コード例 #10
0
ファイル: assert_eos_matcher.hpp プロジェクト: AlexS2172/IVRM
 static bool match(state_type<BidiIter> &state, Next const &next)
 {
     return state.eos() && next.match(state);
 }