forked from boostorg/regex
Added support for independent subs
Almost complete implementation now [SVN r18205]
This commit is contained in:
@ -129,7 +129,7 @@ struct saved_single_repeat : public saved_state
|
|||||||
const re_repeat* rep;
|
const re_repeat* rep;
|
||||||
BidiIterator last_position;
|
BidiIterator last_position;
|
||||||
saved_single_repeat(unsigned c, const re_repeat* r, BidiIterator lp, int id)
|
saved_single_repeat(unsigned c, const re_repeat* r, BidiIterator lp, int id)
|
||||||
: saved_state(id), count(c), last_position(lp), rep(r){}
|
: saved_state(id), count(c), rep(r), last_position(lp){}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class BidiIterator, class Allocator, class traits, class Allocator2>
|
template <class BidiIterator, class Allocator, class traits, class Allocator2>
|
||||||
@ -299,6 +299,15 @@ bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_startmark(
|
|||||||
push_assertion(next_pstate, index == -1);
|
push_assertion(next_pstate, index == -1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case -3:
|
||||||
|
{
|
||||||
|
// independent sub-expression:
|
||||||
|
const re_syntax_base* next_pstate = static_cast<const re_jump*>(pstate->next.p)->alt.p->next.p;
|
||||||
|
pstate = pstate->next.p->next.p;
|
||||||
|
bool r = match_all_states();
|
||||||
|
pstate = next_pstate;
|
||||||
|
return r;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
assert(index > 0);
|
assert(index > 0);
|
||||||
|
@ -93,6 +93,15 @@ bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::match_startmark(
|
|||||||
r = true;
|
r = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case -3:
|
||||||
|
{
|
||||||
|
// independent sub-expression:
|
||||||
|
const re_syntax_base* next_pstate = static_cast<const re_jump*>(pstate->next.p)->alt.p->next.p;
|
||||||
|
pstate = pstate->next.p->next.p;
|
||||||
|
r = match_all_states();
|
||||||
|
pstate = next_pstate;
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
assert(index > 0);
|
assert(index > 0);
|
||||||
@ -625,9 +634,10 @@ bool perl_matcher<BidiIterator, Allocator, traits, Allocator2>::backtrack_till_m
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace re_detail
|
||||||
} // namespace boost
|
} // namespace boost
|
||||||
|
|
||||||
|
|
||||||
#ifdef __BORLANDC__
|
#ifdef __BORLANDC__
|
||||||
# pragma option pop
|
# pragma option pop
|
||||||
#endif
|
#endif
|
||||||
|
@ -447,6 +447,8 @@ void BOOST_REGEX_CALL reg_expression<charT, traits, Allocator>::compile_maps()
|
|||||||
if(static_cast<re_detail::re_set_long*>(rep->next.p)->singleton)
|
if(static_cast<re_detail::re_set_long*>(rep->next.p)->singleton)
|
||||||
rep->type = re_detail::syntax_element_long_set_rep;
|
rep->type = re_detail::syntax_element_long_set_rep;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -475,8 +477,18 @@ bool BOOST_REGEX_CALL reg_expression<charT, traits, Allocator>::probe_start(
|
|||||||
return probe_start(node->next.p->next.p, cc, terminal)
|
return probe_start(node->next.p->next.p, cc, terminal)
|
||||||
&& probe_start(static_cast<const re_detail::re_jump*>(node->next.p)->alt.p, cc, terminal);
|
&& probe_start(static_cast<const re_detail::re_jump*>(node->next.p)->alt.p, cc, terminal);
|
||||||
}
|
}
|
||||||
// fall through:
|
else if(static_cast<const re_detail::re_brace*>(node)->index == -3)
|
||||||
|
{
|
||||||
|
return probe_start(node->next.p->next.p, cc, terminal);
|
||||||
|
}
|
||||||
|
// doesn't tell us anything about the next character, so:
|
||||||
|
return probe_start(node->next.p, cc, terminal);
|
||||||
case re_detail::syntax_element_endmark:
|
case re_detail::syntax_element_endmark:
|
||||||
|
if(static_cast<const re_detail::re_brace*>(node)->index == -3)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// fall through:
|
||||||
case re_detail::syntax_element_start_line:
|
case re_detail::syntax_element_start_line:
|
||||||
case re_detail::syntax_element_word_boundary:
|
case re_detail::syntax_element_word_boundary:
|
||||||
case re_detail::syntax_element_buffer_start:
|
case re_detail::syntax_element_buffer_start:
|
||||||
@ -561,6 +573,10 @@ bool BOOST_REGEX_CALL reg_expression<charT, traits, Allocator>::probe_start(
|
|||||||
// we need to take the OR of the two alternatives:
|
// we need to take the OR of the two alternatives:
|
||||||
return probe_start(static_cast<re_detail::re_jump*>(node)->alt.p, cc, terminal) || probe_start(node->next.p, cc, terminal);
|
return probe_start(static_cast<re_detail::re_jump*>(node)->alt.p, cc, terminal) || probe_start(node->next.p, cc, terminal);
|
||||||
case re_detail::syntax_element_rep:
|
case re_detail::syntax_element_rep:
|
||||||
|
case re_detail::syntax_element_char_rep:
|
||||||
|
case re_detail::syntax_element_dot_rep:
|
||||||
|
case re_detail::syntax_element_long_set_rep:
|
||||||
|
case re_detail::syntax_element_short_set_rep:
|
||||||
// we need to take the OR of the two alternatives
|
// we need to take the OR of the two alternatives
|
||||||
if(static_cast<re_detail::re_repeat*>(node)->min == 0)
|
if(static_cast<re_detail::re_repeat*>(node)->min == 0)
|
||||||
return probe_start(node->next.p, cc, static_cast<re_detail::re_jump*>(node)->alt.p) || probe_start(static_cast<re_detail::re_jump*>(node)->alt.p, cc, terminal);
|
return probe_start(node->next.p, cc, static_cast<re_detail::re_jump*>(node)->alt.p) || probe_start(static_cast<re_detail::re_jump*>(node)->alt.p, cc, terminal);
|
||||||
@ -1403,6 +1419,11 @@ unsigned int BOOST_REGEX_CALL reg_expression<charT, traits, Allocator>::set_expr
|
|||||||
static_cast<re_detail::re_jump*>(dat)->alt.i = INT_MAX/2;
|
static_cast<re_detail::re_jump*>(dat)->alt.i = INT_MAX/2;
|
||||||
mark.push(data.size() - re_detail::re_jump_size);
|
mark.push(data.size() - re_detail::re_jump_size);
|
||||||
continue;
|
continue;
|
||||||
|
case traits_type::syntax_right_word:
|
||||||
|
static_cast<re_detail::re_brace*>(dat)->index = -3;
|
||||||
|
markid.pop();
|
||||||
|
markid.push(-3);
|
||||||
|
goto common_forward_assert;
|
||||||
case traits_type::syntax_not:
|
case traits_type::syntax_not:
|
||||||
static_cast<re_detail::re_brace*>(dat)->index = -2;
|
static_cast<re_detail::re_brace*>(dat)->index = -2;
|
||||||
markid.pop();
|
markid.pop();
|
||||||
|
@ -136,7 +136,7 @@ inline bool regex_match(const wchar_t* str,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
inline bool regex_match(const std::string& s,
|
inline bool regex_match(const std::string& s,
|
||||||
match_results<std::string::const_iterator, regex::allocator_type>& m,
|
smatch& m,
|
||||||
const regex& e,
|
const regex& e,
|
||||||
match_flag_type flags = match_default)
|
match_flag_type flags = match_default)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user