本文整理汇总了C++中match_state::sub_match方法的典型用法代码示例。如果您正苦于以下问题:C++ match_state::sub_match方法的具体用法?C++ match_state::sub_match怎么用?C++ match_state::sub_match使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类match_state
的用法示例。
在下文中一共展示了match_state::sub_match方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: match
bool match(match_state<BidiIter> &state, Next const &next) const
{
BOOST_ASSERT(this->mark_number_ < static_cast<int>(state.mark_count_));
sub_match_impl<BidiIter> const &br = state.sub_match(this->mark_number_);
if(!br.matched)
{
return false;
}
BidiIter const tmp = state.cur_;
for(BidiIter begin = br.first, end = br.second; begin != end; ++begin, ++state.cur_)
{
if(state.eos()
|| detail::translate(*state.cur_, traits_cast<Traits>(state), icase_type())
!= detail::translate(*begin, traits_cast<Traits>(state), icase_type()))
{
state.cur_ = tmp;
return false;
}
}
if(next.match(state))
{
return true;
}
state.cur_ = tmp;
return false;
}
示例2: match_next
inline bool match_next(match_state<BidiIter> &state, Next const &next, int mark_number)
{
sub_match_impl<BidiIter> &br = state.sub_match(mark_number);
bool old_matched = br.matched;
br.matched = false;
if(next.match(state))
{
return true;
}
br.matched = old_matched;
return false;
}
示例3: match
static bool match(match_state<BidiIter> &state, Next const &)
{
BidiIter const tmp = state.cur_;
sub_match_impl<BidiIter> &s0 = state.sub_match(0);
BOOST_ASSERT(!s0.matched);
// SPECIAL: if there is a match context on the context stack, then
// this pattern has been nested within another. pop that context and
// continue executing.
if(0 != state.context_.prev_context_)
{
if(!pop_context_match(state))
{
return false;
}
// record the end of sub-match zero
s0.first = s0.begin_;
s0.second = tmp;
s0.matched = true;
return true;
}
else if((state.flags_.match_all_ && !state.eos()) ||
(state.flags_.match_not_null_ && state.cur_ == s0.begin_))
{
return false;
}
// record the end of sub-match zero
s0.first = s0.begin_;
s0.second = tmp;
s0.matched = true;
// Now execute any actions that have been queued
for(actionable const *actor = state.action_list_.next; 0 != actor; actor = actor->next)
{
actor->execute(state.action_args_);
}
return true;
}
示例4: match_
bool match_(match_state<BidiIter> &state, Next const &next, mpl::true_) const
{
sub_match_impl<BidiIter> &br = state.sub_match(this->mark_number_);
if(this->max_ > br.repeat_count_)
{
++br.repeat_count_;
// loop back to the expression "pushed" in repeat_begin_matcher::match
if(next.top_match(state, this->back_))
{
return true;
}
else if(--br.repeat_count_ < this->min_)
{
return false;
}
}
// looping finished, continue matching the rest of the pattern
return next.skip_match(state);
}
示例5: match
bool match(match_state<BidiIter> &state, Next const &next) const
{
// prevent repeated zero-width sub-matches from causing infinite recursion
sub_match_impl<BidiIter> &br = state.sub_match(this->mark_number_);
if(br.zero_width_ && br.begin_ == state.cur_)
{
return next.skip_match(state);
}
bool old_zero_width = br.zero_width_;
br.zero_width_ = (br.begin_ == state.cur_);
if(this->match_(state, next, greedy_type()))
{
return true;
}
br.zero_width_ = old_zero_width;
return false;
}
示例6: match
bool match(match_state<BidiIter> &state, Next const &next) const
{
sub_match_impl<BidiIter> &br = state.sub_match(this->mark_number_);
unsigned int old_repeat_count = br.repeat_count_;
bool old_zero_width = br.zero_width_;
br.repeat_count_ = 1;
br.zero_width_ = false;
// "push" next onto the stack, so it can be "popped" in
// repeat_end_matcher and used to loop back.
if(next.BOOST_NESTED_TEMPLATE push_match<Next>(state))
{
return true;
}
br.repeat_count_ = old_repeat_count;
br.zero_width_ = old_zero_width;
return false;
}