Commit d860c842 by Paolo Carlini Committed by Paolo Carlini

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
parent 83e279c4
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>
* testsuite/util/testsuite_hooks.h: Cast fn to bool.
......
......@@ -451,7 +451,8 @@ namespace std
*/
template<typename _Ch_traits, typename _Ch_alloc>
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)
: _M_flags(__f),
_M_automaton(__regex::__compile(__s.begin(), __s.end(),
......
......@@ -34,7 +34,8 @@ namespace __regex
{
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_in_brace = 1 << 2;
......@@ -256,7 +257,8 @@ namespace __regex
_M_curToken = _S_token_dup_count;
_M_curValue.assign(1, *_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_current;
......@@ -272,7 +274,7 @@ namespace __regex
if (_M_flags & (regex_constants::basic | regex_constants::grep))
{
if (*_M_current == _M_ctype.widen('\\'))
{ _M_eat_escape(); }
_M_eat_escape();
}
else
{
......@@ -337,8 +339,8 @@ namespace __regex
if (!(_M_flags & regex_constants::ECMAScript)
|| !(_M_state & _S_state_at_start))
{
// special case: only if _not_ chr first after '[' or '[^' and if not
// ECMAscript
// special case: only if _not_ chr first after
// '[' or '[^' and if not ECMAscript
_M_curToken = _S_token_bracket_end;
++_M_current;
return;
......@@ -371,10 +373,8 @@ namespace __regex
_M_curValue.assign(1, __c);
}
else
{
_M_curToken = _S_token_subexpr_begin;
}
}
else if (__c == _M_ctype.widen(')'))
{
if (!(_M_flags & (regex_constants::basic | regex_constants::grep)))
......@@ -383,10 +383,8 @@ namespace __regex
_M_curValue.assign(1, __c);
}
else
{
_M_curToken = _S_token_subexpr_end;
}
}
else if (__c == _M_ctype.widen('{'))
{
if (!(_M_flags & (regex_constants::basic | regex_constants::grep)))
......@@ -455,10 +453,8 @@ namespace __regex
_M_curValue.assign(1, __c);
}
else
{
__throw_regex_error(regex_constants::error_escape);
}
}
// Eats a character class or throwns an exception.
......@@ -648,7 +644,7 @@ namespace __regex
// accepts a specific token or returns false.
bool
_M_match_token(_TokenT token);
_M_match_token(_TokenT __token);
void
_M_disjunction();
......@@ -731,8 +727,8 @@ namespace __regex
__r._M_append(_M_stack.top());
_M_stack.pop();
}
__r._M_append(_M_state_store._M_insert_subexpr_end(0,
bind(_End(0), _1, _2)));
__r._M_append(_M_state_store.
_M_insert_subexpr_end(0, bind(_End(0), _1, _2)));
__r._M_append(_M_state_store._M_insert_accept());
}
......@@ -848,7 +844,8 @@ namespace __regex
if (_M_stack.empty())
__throw_regex_error(regex_constants::error_badrepeat);
_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_append(__r);
return true;
......@@ -881,7 +878,8 @@ namespace __regex
for (int __i = 0; __i < __n; ++__i)
{
_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_append(__r);
}
......@@ -915,22 +913,26 @@ namespace __regex
if (_M_match_token(_ScannerT::_S_token_anychar))
{
_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;
}
if (_M_match_token(_ScannerT::_S_token_ord_char))
{
_M_stack.push(_StateSeq(_M_state_store,
_M_state_store._M_insert_matcher(
bind(_CMatcher(_M_cur_value[0], _M_traits), _1))));
_M_stack.push(_StateSeq
(_M_state_store, _M_state_store.
_M_insert_matcher
(bind(_CMatcher(_M_cur_value[0], _M_traits), _1))));
return true;
}
if (_M_match_token(_ScannerT::_S_token_quoted_char))
{
// note that in the ECMA grammar, this case covers backrefs.
_M_stack.push(_StateSeq(_M_state_store,
_M_state_store._M_insert_matcher(
bind(_CMatcher(_M_cur_value[0], _M_traits), _1))));
_M_state_store.
_M_insert_matcher
(bind(_CMatcher(_M_cur_value[0], _M_traits),
_1))));
return true;
}
if (_M_match_token(_ScannerT::_S_token_backref))
......@@ -942,7 +944,8 @@ namespace __regex
{
int __mark = _M_state_store._M_sub_count();
_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();
if (!_M_match_token(_ScannerT::_S_token_subexpr_end))
__throw_regex_error(regex_constants::error_paren);
......@@ -951,8 +954,8 @@ namespace __regex
__r._M_append(_M_stack.top());
_M_stack.pop();
}
__r._M_append(_M_state_store._M_insert_subexpr_end(__mark,
bind(_End(__mark), _1, _2)));
__r._M_append(_M_state_store._M_insert_subexpr_end
(__mark, bind(_End(__mark), _1, _2)));
_M_stack.push(__r);
return true;
}
......@@ -974,8 +977,8 @@ namespace __regex
|| !_M_match_token(_ScannerT::_S_token_bracket_end))
__throw_regex_error(regex_constants::error_brack);
_M_stack.push(_StateSeq(_M_state_store,
_M_state_store._M_insert_matcher(
bind(__matcher, _1))));
_M_state_store._M_insert_matcher
(bind(__matcher, _1))));
return true;
}
return false;
......@@ -1018,10 +1021,11 @@ namespace __regex
_Compiler<_InIter, _TraitsT>::
_M_expression_term(_RMatcherT& __matcher)
{
return _M_collating_symbol(__matcher)
return (_M_collating_symbol(__matcher)
|| _M_character_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>
......
......@@ -82,7 +82,7 @@ namespace __regex
// Helper funxtion to create a cursor specialized for an iterator class.
template<typename _FwdIterT>
_SpecializedCursor<_FwdIterT>
inline _SpecializedCursor<_FwdIterT>
__cursor(const _FwdIterT& __b, const _FwdIterT __e)
{ return _SpecializedCursor<_FwdIterT>(__b, __e); }
......
......@@ -34,8 +34,7 @@ namespace
{
// A stack of states used in evaluating the NFA.
typedef std::stack<
std::__regex::_StateIdT,
typedef std::stack<std::__regex::_StateIdT,
std::vector<std::__regex::_StateIdT>
> _StateStack;
......@@ -102,8 +101,7 @@ namespace
namespace __regex
{
inline _Grep_matcher::
_Grep_matcher(_PatternCursor& __p,
_Results& __r,
_Grep_matcher(_PatternCursor& __p, _Results& __r,
const _AutomatonPtr& __nfa,
regex_constants::match_flag_type __flags)
: _M_nfa(static_pointer_cast<_Nfa>(__nfa)), _M_pattern(__p), _M_results(__r)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment