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(),
|
||||||
|
|
|
@ -34,7 +34,8 @@ namespace __regex
|
||||||
{
|
{
|
||||||
struct _Scanner_base
|
struct _Scanner_base
|
||||||
{
|
{
|
||||||
typedef unsigned int _StateT; // FIXME: replace these constanst with constexpr
|
// FIXME: replace these constanst with constexpr
|
||||||
|
typedef unsigned int _StateT;
|
||||||
|
|
||||||
static const _StateT _S_state_at_start = 1 << 0;
|
static const _StateT _S_state_at_start = 1 << 0;
|
||||||
static const _StateT _S_state_in_brace = 1 << 2;
|
static const _StateT _S_state_in_brace = 1 << 2;
|
||||||
|
@ -256,7 +257,8 @@ namespace __regex
|
||||||
_M_curToken = _S_token_dup_count;
|
_M_curToken = _S_token_dup_count;
|
||||||
_M_curValue.assign(1, *_M_current);
|
_M_curValue.assign(1, *_M_current);
|
||||||
++_M_current;
|
++_M_current;
|
||||||
while (_M_current != _M_end && _M_ctype.is(_CtypeT::digit, *_M_current))
|
while (_M_current != _M_end
|
||||||
|
&& _M_ctype.is(_CtypeT::digit, *_M_current))
|
||||||
{
|
{
|
||||||
_M_curValue += *_M_current;
|
_M_curValue += *_M_current;
|
||||||
++_M_current;
|
++_M_current;
|
||||||
|
@ -272,7 +274,7 @@ namespace __regex
|
||||||
if (_M_flags & (regex_constants::basic | regex_constants::grep))
|
if (_M_flags & (regex_constants::basic | regex_constants::grep))
|
||||||
{
|
{
|
||||||
if (*_M_current == _M_ctype.widen('\\'))
|
if (*_M_current == _M_ctype.widen('\\'))
|
||||||
{ _M_eat_escape(); }
|
_M_eat_escape();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -337,8 +339,8 @@ namespace __regex
|
||||||
if (!(_M_flags & regex_constants::ECMAScript)
|
if (!(_M_flags & regex_constants::ECMAScript)
|
||||||
|| !(_M_state & _S_state_at_start))
|
|| !(_M_state & _S_state_at_start))
|
||||||
{
|
{
|
||||||
// special case: only if _not_ chr first after '[' or '[^' and if not
|
// special case: only if _not_ chr first after
|
||||||
// ECMAscript
|
// '[' or '[^' and if not ECMAscript
|
||||||
_M_curToken = _S_token_bracket_end;
|
_M_curToken = _S_token_bracket_end;
|
||||||
++_M_current;
|
++_M_current;
|
||||||
return;
|
return;
|
||||||
|
@ -371,10 +373,8 @@ namespace __regex
|
||||||
_M_curValue.assign(1, __c);
|
_M_curValue.assign(1, __c);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
_M_curToken = _S_token_subexpr_begin;
|
_M_curToken = _S_token_subexpr_begin;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else if (__c == _M_ctype.widen(')'))
|
else if (__c == _M_ctype.widen(')'))
|
||||||
{
|
{
|
||||||
if (!(_M_flags & (regex_constants::basic | regex_constants::grep)))
|
if (!(_M_flags & (regex_constants::basic | regex_constants::grep)))
|
||||||
|
@ -383,10 +383,8 @@ namespace __regex
|
||||||
_M_curValue.assign(1, __c);
|
_M_curValue.assign(1, __c);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
_M_curToken = _S_token_subexpr_end;
|
_M_curToken = _S_token_subexpr_end;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else if (__c == _M_ctype.widen('{'))
|
else if (__c == _M_ctype.widen('{'))
|
||||||
{
|
{
|
||||||
if (!(_M_flags & (regex_constants::basic | regex_constants::grep)))
|
if (!(_M_flags & (regex_constants::basic | regex_constants::grep)))
|
||||||
|
@ -455,10 +453,8 @@ namespace __regex
|
||||||
_M_curValue.assign(1, __c);
|
_M_curValue.assign(1, __c);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
__throw_regex_error(regex_constants::error_escape);
|
__throw_regex_error(regex_constants::error_escape);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Eats a character class or throwns an exception.
|
// Eats a character class or throwns an exception.
|
||||||
|
@ -648,7 +644,7 @@ namespace __regex
|
||||||
|
|
||||||
// accepts a specific token or returns false.
|
// accepts a specific token or returns false.
|
||||||
bool
|
bool
|
||||||
_M_match_token(_TokenT token);
|
_M_match_token(_TokenT __token);
|
||||||
|
|
||||||
void
|
void
|
||||||
_M_disjunction();
|
_M_disjunction();
|
||||||
|
@ -731,8 +727,8 @@ namespace __regex
|
||||||
__r._M_append(_M_stack.top());
|
__r._M_append(_M_stack.top());
|
||||||
_M_stack.pop();
|
_M_stack.pop();
|
||||||
}
|
}
|
||||||
__r._M_append(_M_state_store._M_insert_subexpr_end(0,
|
__r._M_append(_M_state_store.
|
||||||
bind(_End(0), _1, _2)));
|
_M_insert_subexpr_end(0, bind(_End(0), _1, _2)));
|
||||||
__r._M_append(_M_state_store._M_insert_accept());
|
__r._M_append(_M_state_store._M_insert_accept());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -848,7 +844,8 @@ namespace __regex
|
||||||
if (_M_stack.empty())
|
if (_M_stack.empty())
|
||||||
__throw_regex_error(regex_constants::error_badrepeat);
|
__throw_regex_error(regex_constants::error_badrepeat);
|
||||||
_StateSeq __r(_M_state_store,
|
_StateSeq __r(_M_state_store,
|
||||||
_M_state_store._M_insert_alt(_S_invalid_state_id,
|
_M_state_store.
|
||||||
|
_M_insert_alt(_S_invalid_state_id,
|
||||||
_M_stack.top()._M_front()));
|
_M_stack.top()._M_front()));
|
||||||
_M_stack.top()._M_append(__r);
|
_M_stack.top()._M_append(__r);
|
||||||
return true;
|
return true;
|
||||||
|
@ -881,7 +878,8 @@ namespace __regex
|
||||||
for (int __i = 0; __i < __n; ++__i)
|
for (int __i = 0; __i < __n; ++__i)
|
||||||
{
|
{
|
||||||
_StateSeq __r(_M_state_store,
|
_StateSeq __r(_M_state_store,
|
||||||
_M_state_store._M_insert_alt(_S_invalid_state_id,
|
_M_state_store.
|
||||||
|
_M_insert_alt(_S_invalid_state_id,
|
||||||
_M_stack.top()._M_front()));
|
_M_stack.top()._M_front()));
|
||||||
_M_stack.top()._M_append(__r);
|
_M_stack.top()._M_append(__r);
|
||||||
}
|
}
|
||||||
|
@ -915,22 +913,26 @@ namespace __regex
|
||||||
if (_M_match_token(_ScannerT::_S_token_anychar))
|
if (_M_match_token(_ScannerT::_S_token_anychar))
|
||||||
{
|
{
|
||||||
_M_stack.push(_StateSeq(_M_state_store,
|
_M_stack.push(_StateSeq(_M_state_store,
|
||||||
_M_state_store._M_insert_matcher(bind(_AnyMatcher, _1))));
|
_M_state_store.
|
||||||
|
_M_insert_matcher(bind(_AnyMatcher, _1))));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (_M_match_token(_ScannerT::_S_token_ord_char))
|
if (_M_match_token(_ScannerT::_S_token_ord_char))
|
||||||
{
|
{
|
||||||
_M_stack.push(_StateSeq(_M_state_store,
|
_M_stack.push(_StateSeq
|
||||||
_M_state_store._M_insert_matcher(
|
(_M_state_store, _M_state_store.
|
||||||
bind(_CMatcher(_M_cur_value[0], _M_traits), _1))));
|
_M_insert_matcher
|
||||||
|
(bind(_CMatcher(_M_cur_value[0], _M_traits), _1))));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (_M_match_token(_ScannerT::_S_token_quoted_char))
|
if (_M_match_token(_ScannerT::_S_token_quoted_char))
|
||||||
{
|
{
|
||||||
// note that in the ECMA grammar, this case covers backrefs.
|
// note that in the ECMA grammar, this case covers backrefs.
|
||||||
_M_stack.push(_StateSeq(_M_state_store,
|
_M_stack.push(_StateSeq(_M_state_store,
|
||||||
_M_state_store._M_insert_matcher(
|
_M_state_store.
|
||||||
bind(_CMatcher(_M_cur_value[0], _M_traits), _1))));
|
_M_insert_matcher
|
||||||
|
(bind(_CMatcher(_M_cur_value[0], _M_traits),
|
||||||
|
_1))));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (_M_match_token(_ScannerT::_S_token_backref))
|
if (_M_match_token(_ScannerT::_S_token_backref))
|
||||||
|
@ -942,7 +944,8 @@ namespace __regex
|
||||||
{
|
{
|
||||||
int __mark = _M_state_store._M_sub_count();
|
int __mark = _M_state_store._M_sub_count();
|
||||||
_StateSeq __r(_M_state_store,
|
_StateSeq __r(_M_state_store,
|
||||||
_M_state_store._M_insert_subexpr_begin(bind(_Start(__mark), _1, _2)));
|
_M_state_store.
|
||||||
|
_M_insert_subexpr_begin(bind(_Start(__mark), _1, _2)));
|
||||||
this->_M_disjunction();
|
this->_M_disjunction();
|
||||||
if (!_M_match_token(_ScannerT::_S_token_subexpr_end))
|
if (!_M_match_token(_ScannerT::_S_token_subexpr_end))
|
||||||
__throw_regex_error(regex_constants::error_paren);
|
__throw_regex_error(regex_constants::error_paren);
|
||||||
|
@ -951,8 +954,8 @@ namespace __regex
|
||||||
__r._M_append(_M_stack.top());
|
__r._M_append(_M_stack.top());
|
||||||
_M_stack.pop();
|
_M_stack.pop();
|
||||||
}
|
}
|
||||||
__r._M_append(_M_state_store._M_insert_subexpr_end(__mark,
|
__r._M_append(_M_state_store._M_insert_subexpr_end
|
||||||
bind(_End(__mark), _1, _2)));
|
(__mark, bind(_End(__mark), _1, _2)));
|
||||||
_M_stack.push(__r);
|
_M_stack.push(__r);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -974,8 +977,8 @@ namespace __regex
|
||||||
|| !_M_match_token(_ScannerT::_S_token_bracket_end))
|
|| !_M_match_token(_ScannerT::_S_token_bracket_end))
|
||||||
__throw_regex_error(regex_constants::error_brack);
|
__throw_regex_error(regex_constants::error_brack);
|
||||||
_M_stack.push(_StateSeq(_M_state_store,
|
_M_stack.push(_StateSeq(_M_state_store,
|
||||||
_M_state_store._M_insert_matcher(
|
_M_state_store._M_insert_matcher
|
||||||
bind(__matcher, _1))));
|
(bind(__matcher, _1))));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -1018,10 +1021,11 @@ namespace __regex
|
||||||
_Compiler<_InIter, _TraitsT>::
|
_Compiler<_InIter, _TraitsT>::
|
||||||
_M_expression_term(_RMatcherT& __matcher)
|
_M_expression_term(_RMatcherT& __matcher)
|
||||||
{
|
{
|
||||||
return _M_collating_symbol(__matcher)
|
return (_M_collating_symbol(__matcher)
|
||||||
|| _M_character_class(__matcher)
|
|| _M_character_class(__matcher)
|
||||||
|| _M_equivalence_class(__matcher)
|
|| _M_equivalence_class(__matcher)
|
||||||
|| (_M_start_range(__matcher) && _M_range_expression(__matcher));
|
|| (_M_start_range(__matcher)
|
||||||
|
&& _M_range_expression(__matcher)));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename _InIter, typename _TraitsT>
|
template<typename _InIter, typename _TraitsT>
|
||||||
|
|
|
@ -82,7 +82,7 @@ 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); }
|
||||||
|
|
||||||
|
|
|
@ -34,8 +34,7 @@ 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;
|
||||||
|
|
||||||
|
@ -102,8 +101,7 @@ 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)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue