Boost-Graph
view release on metacpan or search on metacpan
include/boost/regex/v4/basic_regex_parser.hpp view on Meta::CPAN
do
{
while((m_position != m_end)
&& (this->m_traits.syntax_type(*m_position) != regex_constants::syntax_escape))
++m_position;
if(m_position == m_end)
{
// a \Q...\E sequence may terminate with the end of the expression:
end = m_position;
break;
}
if(++m_position == m_end) // skip the escape
{
fail(regex_constants::error_escape, m_position - m_base);
return false;
}
// check to see if it's a \E:
if(this->m_traits.escape_syntax_type(*m_position) == regex_constants::escape_type_E)
{
++m_position;
end = m_position - 2;
break;
}
// otherwise go round again:
}while(true);
//
// now add all the character between the two escapes as literals:
//
while(start != end)
{
this->append_literal(*start);
++start;
}
return true;
#ifdef BOOST_MSVC
#pragma warning(pop)
#endif
}
template <class charT, class traits>
bool basic_regex_parser<charT, traits>::parse_perl_extension()
{
if(++m_position == m_end)
{
fail(regex_constants::error_badrepeat, m_position - m_base);
return false;
}
//
// treat comments as a special case, as these
// are the only ones that don't start with a leading
// startmark state:
//
if(this->m_traits.syntax_type(*m_position) == regex_constants::syntax_hash)
{
while((m_position != m_end)
&& (this->m_traits.syntax_type(*m_position++) != regex_constants::syntax_close_mark))
{}
return true;
}
//
// backup some state, and prepare the way:
//
int markid = 0;
std::ptrdiff_t jump_offset = 0;
re_brace* pb = static_cast<re_brace*>(this->append_state(syntax_element_startmark, sizeof(re_brace)));
std::ptrdiff_t last_paren_start = this->getoffset(pb);
// back up insertion point for alternations, and set new point:
std::ptrdiff_t last_alt_point = m_alt_insert_point;
this->m_pdata->m_data.align();
m_alt_insert_point = this->m_pdata->m_data.size();
std::ptrdiff_t expected_alt_point = m_alt_insert_point;
bool restore_flags = true;
regex_constants::syntax_option_type old_flags = this->flags();
bool old_case_change = m_has_case_change;
m_has_case_change = false;
//
// select the actual extension used:
//
switch(this->m_traits.syntax_type(*m_position))
{
case regex_constants::syntax_colon:
//
// a non-capturing mark:
//
pb->index = markid = 0;
++m_position;
break;
case regex_constants::syntax_equal:
pb->index = markid = -1;
++m_position;
jump_offset = this->getoffset(this->append_state(syntax_element_jump, sizeof(re_jump)));
this->m_pdata->m_data.align();
m_alt_insert_point = this->m_pdata->m_data.size();
break;
case regex_constants::syntax_not:
pb->index = markid = -2;
++m_position;
jump_offset = this->getoffset(this->append_state(syntax_element_jump, sizeof(re_jump)));
this->m_pdata->m_data.align();
m_alt_insert_point = this->m_pdata->m_data.size();
break;
case regex_constants::escape_type_left_word:
{
// a lookbehind assertion:
if(++m_position == m_end)
{
fail(regex_constants::error_badrepeat, m_position - m_base);
return false;
}
regex_constants::syntax_type t = this->m_traits.syntax_type(*m_position);
if(t == regex_constants::syntax_not)
pb->index = markid = -2;
else if(t == regex_constants::syntax_equal)
pb->index = markid = -1;
else
{
fail(regex_constants::error_badrepeat, m_position - m_base);
return false;
}
++m_position;
jump_offset = this->getoffset(this->append_state(syntax_element_jump, sizeof(re_jump)));
( run in 3.293 seconds using v1.01-cache-2.11-cpan-97f6503c9c8 )