regex_compiler.h: Trivial formatting / stylistic fixes.
2010-06-27 Paolo Carlini <paolo.carlini@oracle.com> * include/bits/regex_compiler.h: Trivial formatting / stylistic fixes. * include/bits/regex_grep_matcher.tcc: Likewise. * include/bits/regex_cursor.h: Likewise. * include/bits/regex.h: Likewise. From-SVN: r161462
This commit is contained in:
parent
83e279c4c3
commit
d860c8424c
5 changed files with 543 additions and 533 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
2010-06-27 Paolo Carlini <paolo.carlini@oracle.com>
|
||||||
|
|
||||||
|
* include/bits/regex_compiler.h: Trivial formatting / stylistic fixes.
|
||||||
|
* include/bits/regex_grep_matcher.tcc: Likewise.
|
||||||
|
* include/bits/regex_cursor.h: Likewise.
|
||||||
|
* include/bits/regex.h: Likewise.
|
||||||
|
|
||||||
2010-06-26 Paolo Carlini <paolo.carlini@oracle.com>
|
2010-06-26 Paolo Carlini <paolo.carlini@oracle.com>
|
||||||
|
|
||||||
* testsuite/util/testsuite_hooks.h: Cast fn to bool.
|
* testsuite/util/testsuite_hooks.h: Cast fn to bool.
|
||||||
|
|
|
@ -451,7 +451,8 @@ namespace std
|
||||||
*/
|
*/
|
||||||
template<typename _Ch_traits, typename _Ch_alloc>
|
template<typename _Ch_traits, typename _Ch_alloc>
|
||||||
explicit
|
explicit
|
||||||
basic_regex(const std::basic_string<_Ch_type, _Ch_traits, _Ch_alloc>& __s,
|
basic_regex(const std::basic_string<_Ch_type, _Ch_traits,
|
||||||
|
_Ch_alloc>& __s,
|
||||||
flag_type __f = regex_constants::ECMAScript)
|
flag_type __f = regex_constants::ECMAScript)
|
||||||
: _M_flags(__f),
|
: _M_flags(__f),
|
||||||
_M_automaton(__regex::__compile(__s.begin(), __s.end(),
|
_M_automaton(__regex::__compile(__s.begin(), __s.end(),
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -64,11 +64,11 @@ namespace __regex
|
||||||
|
|
||||||
const _FwdIterT&
|
const _FwdIterT&
|
||||||
_M_begin() const
|
_M_begin() const
|
||||||
{ return _M_b; }
|
{ return _M_b; }
|
||||||
|
|
||||||
const _FwdIterT&
|
const _FwdIterT&
|
||||||
_M_end() const
|
_M_end() const
|
||||||
{ return _M_e; }
|
{ return _M_e; }
|
||||||
|
|
||||||
bool
|
bool
|
||||||
_M_at_end() const
|
_M_at_end() const
|
||||||
|
@ -82,9 +82,9 @@ namespace __regex
|
||||||
|
|
||||||
// Helper funxtion to create a cursor specialized for an iterator class.
|
// Helper funxtion to create a cursor specialized for an iterator class.
|
||||||
template<typename _FwdIterT>
|
template<typename _FwdIterT>
|
||||||
_SpecializedCursor<_FwdIterT>
|
inline _SpecializedCursor<_FwdIterT>
|
||||||
__cursor(const _FwdIterT& __b, const _FwdIterT __e)
|
__cursor(const _FwdIterT& __b, const _FwdIterT __e)
|
||||||
{ return _SpecializedCursor<_FwdIterT>(__b, __e); }
|
{ return _SpecializedCursor<_FwdIterT>(__b, __e); }
|
||||||
|
|
||||||
} // namespace __regex
|
} // namespace __regex
|
||||||
} // namespace std
|
} // namespace std
|
||||||
|
|
|
@ -34,10 +34,9 @@ namespace
|
||||||
{
|
{
|
||||||
|
|
||||||
// A stack of states used in evaluating the NFA.
|
// A stack of states used in evaluating the NFA.
|
||||||
typedef std::stack<
|
typedef std::stack<std::__regex::_StateIdT,
|
||||||
std::__regex::_StateIdT,
|
|
||||||
std::vector<std::__regex::_StateIdT>
|
std::vector<std::__regex::_StateIdT>
|
||||||
> _StateStack;
|
> _StateStack;
|
||||||
|
|
||||||
// Obtains the next state set given the current state set __s and the current
|
// Obtains the next state set given the current state set __s and the current
|
||||||
// input character.
|
// input character.
|
||||||
|
@ -48,16 +47,16 @@ namespace
|
||||||
{
|
{
|
||||||
std::__regex::_StateSet __m;
|
std::__regex::_StateSet __m;
|
||||||
for (std::__regex::_StateSet::const_iterator __i = __s.begin();
|
for (std::__regex::_StateSet::const_iterator __i = __s.begin();
|
||||||
__i != __s.end(); ++__i)
|
__i != __s.end(); ++__i)
|
||||||
{
|
{
|
||||||
if (*__i == std::__regex::_S_invalid_state_id)
|
if (*__i == std::__regex::_S_invalid_state_id)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const std::__regex::_State& __state = __nfa[*__i];
|
const std::__regex::_State& __state = __nfa[*__i];
|
||||||
if (__state._M_opcode == std::__regex::_S_opcode_match
|
if (__state._M_opcode == std::__regex::_S_opcode_match
|
||||||
&& __state._M_matches(__p))
|
&& __state._M_matches(__p))
|
||||||
__m.insert(__state._M_next);
|
__m.insert(__state._M_next);
|
||||||
}
|
}
|
||||||
return __m;
|
return __m;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,19 +66,19 @@ namespace
|
||||||
const std::__regex::_StateSet& __t)
|
const std::__regex::_StateSet& __t)
|
||||||
{
|
{
|
||||||
if (__s.size() > 0 && __t.size() > 0)
|
if (__s.size() > 0 && __t.size() > 0)
|
||||||
{
|
|
||||||
std::__regex::_StateSet::const_iterator __first = __s.begin();
|
|
||||||
std::__regex::_StateSet::const_iterator __second = __t.begin();
|
|
||||||
while (__first != __s.end() && __second != __t.end())
|
|
||||||
{
|
{
|
||||||
if (*__first < *__second)
|
std::__regex::_StateSet::const_iterator __first = __s.begin();
|
||||||
++__first;
|
std::__regex::_StateSet::const_iterator __second = __t.begin();
|
||||||
else if (*__second < *__first)
|
while (__first != __s.end() && __second != __t.end())
|
||||||
++__second;
|
{
|
||||||
else
|
if (*__first < *__second)
|
||||||
return true;
|
++__first;
|
||||||
|
else if (*__second < *__first)
|
||||||
|
++__second;
|
||||||
|
else
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,10 +90,10 @@ namespace
|
||||||
std::__regex::_StateSet& __e)
|
std::__regex::_StateSet& __e)
|
||||||
{
|
{
|
||||||
if (__e.count(__u) == 0)
|
if (__e.count(__u) == 0)
|
||||||
{
|
{
|
||||||
__e.insert(__u);
|
__e.insert(__u);
|
||||||
__s.push(__u);
|
__s.push(__u);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // anonymous namespace
|
} // anonymous namespace
|
||||||
|
@ -102,9 +101,8 @@ namespace
|
||||||
namespace __regex
|
namespace __regex
|
||||||
{
|
{
|
||||||
inline _Grep_matcher::
|
inline _Grep_matcher::
|
||||||
_Grep_matcher(_PatternCursor& __p,
|
_Grep_matcher(_PatternCursor& __p, _Results& __r,
|
||||||
_Results& __r,
|
const _AutomatonPtr& __nfa,
|
||||||
const _AutomatonPtr& __nfa,
|
|
||||||
regex_constants::match_flag_type __flags)
|
regex_constants::match_flag_type __flags)
|
||||||
: _M_nfa(static_pointer_cast<_Nfa>(__nfa)), _M_pattern(__p), _M_results(__r)
|
: _M_nfa(static_pointer_cast<_Nfa>(__nfa)), _M_pattern(__p), _M_results(__r)
|
||||||
{
|
{
|
||||||
|
@ -142,34 +140,34 @@ namespace __regex
|
||||||
{
|
{
|
||||||
_StateSet __e = __s;
|
_StateSet __e = __s;
|
||||||
while (!__stack.empty())
|
while (!__stack.empty())
|
||||||
{
|
|
||||||
_StateIdT __t = __stack.top(); __stack.pop();
|
|
||||||
if (__t == _S_invalid_state_id)
|
|
||||||
continue;
|
|
||||||
// for each __u with edge from __t to __u labeled e do ...
|
|
||||||
const _State& __state = _M_nfa->operator[](__t);
|
|
||||||
switch (__state._M_opcode)
|
|
||||||
{
|
{
|
||||||
case _S_opcode_alternative:
|
_StateIdT __t = __stack.top(); __stack.pop();
|
||||||
__add_visited_state(__state._M_next, __stack, __e);
|
if (__t == _S_invalid_state_id)
|
||||||
__add_visited_state(__state._M_alt, __stack, __e);
|
continue;
|
||||||
break;
|
// for each __u with edge from __t to __u labeled e do ...
|
||||||
case _S_opcode_subexpr_begin:
|
const _State& __state = _M_nfa->operator[](__t);
|
||||||
__add_visited_state(__state._M_next, __stack, __e);
|
switch (__state._M_opcode)
|
||||||
__state._M_tagger(_M_pattern, _M_results);
|
{
|
||||||
break;
|
case _S_opcode_alternative:
|
||||||
case _S_opcode_subexpr_end:
|
__add_visited_state(__state._M_next, __stack, __e);
|
||||||
__add_visited_state(__state._M_next, __stack, __e);
|
__add_visited_state(__state._M_alt, __stack, __e);
|
||||||
__state._M_tagger(_M_pattern, _M_results);
|
break;
|
||||||
_M_results._M_set_matched(__state._M_subexpr, true);
|
case _S_opcode_subexpr_begin:
|
||||||
break;
|
__add_visited_state(__state._M_next, __stack, __e);
|
||||||
case _S_opcode_accept:
|
__state._M_tagger(_M_pattern, _M_results);
|
||||||
__add_visited_state(__state._M_next, __stack, __e);
|
break;
|
||||||
break;
|
case _S_opcode_subexpr_end:
|
||||||
default:
|
__add_visited_state(__state._M_next, __stack, __e);
|
||||||
break;
|
__state._M_tagger(_M_pattern, _M_results);
|
||||||
|
_M_results._M_set_matched(__state._M_subexpr, true);
|
||||||
|
break;
|
||||||
|
case _S_opcode_accept:
|
||||||
|
__add_visited_state(__state._M_next, __stack, __e);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return __e;
|
return __e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue