Add support for ACCEPT verb.

This commit is contained in:
jzmaddock
2015-09-26 18:47:39 +01:00
parent b557febb0e
commit 2580fb035f
7 changed files with 48 additions and 4 deletions

View File

@ -2715,7 +2715,31 @@ bool basic_regex_parser<charT, traits>::parse_perl_verb()
this->append_state(syntax_element_fail);
return true;
}
return false;
break;
case 'A':
if(++m_position == m_end)
{
// Rewind to start of (* sequence:
--m_position;
while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position;
fail(regex_constants::error_perl_extension, m_position - m_base);
return false;
}
if(match_verb("CCEPT"))
{
if((m_position == m_end) || (this->m_traits.syntax_type(*m_position) != regex_constants::syntax_close_mark))
{
// Rewind to start of (* sequence:
--m_position;
while(this->m_traits.syntax_type(*m_position) != regex_constants::syntax_open_mark) --m_position;
fail(regex_constants::error_perl_extension, m_position - m_base);
return false;
}
++m_position;
this->append_state(syntax_element_accept);
return true;
}
break;
}
return false;
}

View File

@ -444,6 +444,7 @@ private:
#endif
bool match_recursion();
bool match_fail();
bool match_accept();
// find procs stored in s_find_vtable:
bool find_restart_any();

View File

@ -800,6 +800,20 @@ bool perl_matcher<BidiIterator, Allocator, traits>::match_fail()
return false;
}
template <class BidiIterator, class Allocator, class traits>
bool perl_matcher<BidiIterator, Allocator, traits>::match_accept()
{
// Almost the same as match_match, but we need to close any half-open capturing groups:
for(unsigned i = 1; i < m_result.size(); ++i)
{
if((m_result[i].matched == false) && (m_result[i].first != last))
{
m_result.set_second(position, i);
}
}
return match_match();
}
template <class BidiIterator, class Allocator, class traits>
bool perl_matcher<BidiIterator, Allocator, traits>::find_restart_any()

View File

@ -141,7 +141,7 @@ struct saved_recursion : public saved_state
template <class BidiIterator, class Allocator, class traits>
bool perl_matcher<BidiIterator, Allocator, traits>::match_all_states()
{
static matcher_proc_type const s_match_vtable[31] =
static matcher_proc_type const s_match_vtable[32] =
{
(&perl_matcher<BidiIterator, Allocator, traits>::match_startmark),
&perl_matcher<BidiIterator, Allocator, traits>::match_endmark,
@ -178,6 +178,7 @@ bool perl_matcher<BidiIterator, Allocator, traits>::match_all_states()
&perl_matcher<BidiIterator, Allocator, traits>::match_toggle_case,
&perl_matcher<BidiIterator, Allocator, traits>::match_recursion,
&perl_matcher<BidiIterator, Allocator, traits>::match_fail,
&perl_matcher<BidiIterator, Allocator, traits>::match_accept,
};
push_recursion_stopper();

View File

@ -60,7 +60,7 @@ public:
template <class BidiIterator, class Allocator, class traits>
bool perl_matcher<BidiIterator, Allocator, traits>::match_all_states()
{
static matcher_proc_type const s_match_vtable[31] =
static matcher_proc_type const s_match_vtable[32] =
{
(&perl_matcher<BidiIterator, Allocator, traits>::match_startmark),
&perl_matcher<BidiIterator, Allocator, traits>::match_endmark,
@ -97,6 +97,7 @@ bool perl_matcher<BidiIterator, Allocator, traits>::match_all_states()
&perl_matcher<BidiIterator, Allocator, traits>::match_toggle_case,
&perl_matcher<BidiIterator, Allocator, traits>::match_recursion,
&perl_matcher<BidiIterator, Allocator, traits>::match_fail,
&perl_matcher<BidiIterator, Allocator, traits>::match_accept,
};
if(state_count > max_state_count)

View File

@ -123,6 +123,7 @@ enum syntax_element_type
syntax_element_recurse = syntax_element_toggle_case + 1,
// Verbs:
syntax_element_fail = syntax_element_recurse + 1,
syntax_element_accept = syntax_element_fail + 1,
};
#ifdef BOOST_REGEX_DEBUG