Commit e280b6ff by Tim Shen Committed by Tim Shen

regex.h: Replace 8 spaces in indentation with a tab.

2013-08-22  Tim Shen  <timshen91@gmail.com>

	* include/bits/regex.h: Replace 8 spaces in indentation with a tab.
	* include/bits/regex_automaton.h: Same.
	* include/bits/regex_automaton.tcc: Same.
	* include/bits/regex_compiler.h: Same.
	* include/bits/regex_compiler.tcc: Same.
	* include/bits/regex_constants.h: Same.
	* include/bits/regex_executor.h: Same.
	* include/bits/regex_executor.tcc: Same.

From-SVN: r201916
parent 3f97cb0b
2013-08-22 Tim Shen <timshen91@gmail.com>
* include/bits/regex.h: Replace 8 spaces in indentation with a tab.
* include/bits/regex_automaton.h: Same.
* include/bits/regex_automaton.tcc: Same.
* include/bits/regex_compiler.h: Same.
* include/bits/regex_compiler.tcc: Same.
* include/bits/regex_constants.h: Same.
* include/bits/regex_executor.h: Same.
* include/bits/regex_executor.tcc: Same.
2013-08-22 Tim Shen <timshen91@gmail.com>
* include/bits/regex.h: Executor caller.
* include/bits/regex_executor.h: Fix empty grouping problem.
* include/bits/regex_executor.tcc: Same.
......
......@@ -56,71 +56,71 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
typedef std::locale locale_type;
private:
struct _RegexMask
{
typedef typename std::ctype<char_type>::mask _BaseType;
_BaseType _M_base;
unsigned char _M_extended;
static constexpr unsigned char _S_under = 1 << 0;
// FIXME: _S_blank should be removed in the future,
// when locale's complete.
static constexpr unsigned char _S_blank = 1 << 1;
static constexpr unsigned char _S_valid_mask = 0x3;
constexpr _RegexMask(_BaseType __base = 0,
unsigned char __extended = 0)
: _M_base(__base), _M_extended(__extended)
{ }
constexpr _RegexMask
operator&(_RegexMask __other) const
{
return _RegexMask(_M_base & __other._M_base,
_M_extended & __other._M_extended);
}
constexpr _RegexMask
operator|(_RegexMask __other) const
{
return _RegexMask(_M_base | __other._M_base,
_M_extended | __other._M_extended);
}
constexpr _RegexMask
operator^(_RegexMask __other) const
{
return _RegexMask(_M_base ^ __other._M_base,
_M_extended ^ __other._M_extended);
}
constexpr _RegexMask
operator~() const
{ return _RegexMask(~_M_base, ~_M_extended); }
_RegexMask&
operator&=(_RegexMask __other)
{ return *this = (*this) & __other; }
_RegexMask&
operator|=(_RegexMask __other)
{ return *this = (*this) | __other; }
_RegexMask&
operator^=(_RegexMask __other)
{ return *this = (*this) ^ __other; }
constexpr bool
operator==(_RegexMask __other) const
{
return (_M_extended & _S_valid_mask)
== (__other._M_extended & _S_valid_mask)
&& _M_base == __other._M_base;
}
constexpr bool
operator!=(_RegexMask __other) const
{ return !((*this) == __other); }
};
{
typedef typename std::ctype<char_type>::mask _BaseType;
_BaseType _M_base;
unsigned char _M_extended;
static constexpr unsigned char _S_under = 1 << 0;
// FIXME: _S_blank should be removed in the future,
// when locale's complete.
static constexpr unsigned char _S_blank = 1 << 1;
static constexpr unsigned char _S_valid_mask = 0x3;
constexpr _RegexMask(_BaseType __base = 0,
unsigned char __extended = 0)
: _M_base(__base), _M_extended(__extended)
{ }
constexpr _RegexMask
operator&(_RegexMask __other) const
{
return _RegexMask(_M_base & __other._M_base,
_M_extended & __other._M_extended);
}
constexpr _RegexMask
operator|(_RegexMask __other) const
{
return _RegexMask(_M_base | __other._M_base,
_M_extended | __other._M_extended);
}
constexpr _RegexMask
operator^(_RegexMask __other) const
{
return _RegexMask(_M_base ^ __other._M_base,
_M_extended ^ __other._M_extended);
}
constexpr _RegexMask
operator~() const
{ return _RegexMask(~_M_base, ~_M_extended); }
_RegexMask&
operator&=(_RegexMask __other)
{ return *this = (*this) & __other; }
_RegexMask&
operator|=(_RegexMask __other)
{ return *this = (*this) | __other; }
_RegexMask&
operator^=(_RegexMask __other)
{ return *this = (*this) ^ __other; }
constexpr bool
operator==(_RegexMask __other) const
{
return (_M_extended & _S_valid_mask)
== (__other._M_extended & _S_valid_mask)
&& _M_base == __other._M_base;
}
constexpr bool
operator!=(_RegexMask __other) const
{ return !((*this) == __other); }
};
public:
typedef _RegexMask char_class_type;
......@@ -193,9 +193,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* facet.
*/
template<typename _Fwd_iter>
string_type
transform(_Fwd_iter __first, _Fwd_iter __last) const
{
string_type
transform(_Fwd_iter __first, _Fwd_iter __last) const
{
typedef std::collate<char_type> __collate_type;
const __collate_type& __fclt(use_facet<__collate_type>(_M_locale));
string_type __s(__first, __last);
......@@ -217,16 +217,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* @todo Implement this function.
*/
template<typename _Fwd_iter>
string_type
transform_primary(_Fwd_iter __first, _Fwd_iter __last) const
{
typedef std::ctype<char_type> __ctype_type;
const __ctype_type& __fctyp(use_facet<__ctype_type>(_M_locale));
std::vector<char_type> __s(__first, __last);
// FIXME : this is not entirely correct
__fctyp.tolower(__s.data(), __s.data() + __s.size());
return this->transform(__s.data(), __s.data() + __s.size());
}
string_type
transform_primary(_Fwd_iter __first, _Fwd_iter __last) const
{
typedef std::ctype<char_type> __ctype_type;
const __ctype_type& __fctyp(use_facet<__ctype_type>(_M_locale));
std::vector<char_type> __s(__first, __last);
// FIXME : this is not entirely correct
__fctyp.tolower(__s.data(), __s.data() + __s.size());
return this->transform(__s.data(), __s.data() + __s.size());
}
/**
* @brief Gets a collation element by name.
......@@ -240,8 +240,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* character sequence is not a valid collating element.
*/
template<typename _Fwd_iter>
string_type
lookup_collatename(_Fwd_iter __first, _Fwd_iter __last) const;
string_type
lookup_collatename(_Fwd_iter __first, _Fwd_iter __last) const;
/**
* @brief Maps one or more characters to a named character
......@@ -281,9 +281,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* - xdigit
*/
template<typename _Fwd_iter>
char_class_type
lookup_classname(_Fwd_iter __first, _Fwd_iter __last,
bool __icase = false) const;
char_class_type
lookup_classname(_Fwd_iter __first, _Fwd_iter __last,
bool __icase = false) const;
/**
* @brief Determines if @p c is a member of an identified class.
......@@ -353,182 +353,182 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
const __ctype_type& __fctyp(use_facet<__ctype_type>(_M_locale));
static const char* __collatenames[] =
{
"NUL",
"SOH",
"STX",
"ETX",
"EOT",
"ENQ",
"ACK",
"alert",
"backspace",
"tab",
"newline",
"vertical-tab",
"form-feed",
"carriage-return",
"SO",
"SI",
"DLE",
"DC1",
"DC2",
"DC3",
"DC4",
"NAK",
"SYN",
"ETB",
"CAN",
"EM",
"SUB",
"ESC",
"IS4",
"IS3",
"IS2",
"IS1",
"space",
"exclamation-mark",
"quotation-mark",
"number-sign",
"dollar-sign",
"percent-sign",
"ampersand",
"apostrophe",
"left-parenthesis",
"right-parenthesis",
"asterisk",
"plus-sign",
"comma",
"hyphen",
"period",
"slash",
"zero",
"one",
"two",
"three",
"four",
"five",
"six",
"seven",
"eight",
"nine",
"colon",
"semicolon",
"less-than-sign",
"equals-sign",
"greater-than-sign",
"question-mark",
"commercial-at",
"A",
"B",
"C",
"D",
"E",
"F",
"G",
"H",
"I",
"J",
"K",
"L",
"M",
"N",
"O",
"P",
"Q",
"R",
"S",
"T",
"U",
"V",
"W",
"X",
"Y",
"Z",
"left-square-bracket",
"backslash",
"right-square-bracket",
"circumflex",
"underscore",
"grave-accent",
"a",
"b",
"c",
"d",
"e",
"f",
"g",
"h",
"i",
"j",
"k",
"l",
"m",
"n",
"o",
"p",
"q",
"r",
"s",
"t",
"u",
"v",
"w",
"x",
"y",
"z",
"left-curly-bracket",
"vertical-line",
"right-curly-bracket",
"tilde",
"DEL",
""
};
{
"NUL",
"SOH",
"STX",
"ETX",
"EOT",
"ENQ",
"ACK",
"alert",
"backspace",
"tab",
"newline",
"vertical-tab",
"form-feed",
"carriage-return",
"SO",
"SI",
"DLE",
"DC1",
"DC2",
"DC3",
"DC4",
"NAK",
"SYN",
"ETB",
"CAN",
"EM",
"SUB",
"ESC",
"IS4",
"IS3",
"IS2",
"IS1",
"space",
"exclamation-mark",
"quotation-mark",
"number-sign",
"dollar-sign",
"percent-sign",
"ampersand",
"apostrophe",
"left-parenthesis",
"right-parenthesis",
"asterisk",
"plus-sign",
"comma",
"hyphen",
"period",
"slash",
"zero",
"one",
"two",
"three",
"four",
"five",
"six",
"seven",
"eight",
"nine",
"colon",
"semicolon",
"less-than-sign",
"equals-sign",
"greater-than-sign",
"question-mark",
"commercial-at",
"A",
"B",
"C",
"D",
"E",
"F",
"G",
"H",
"I",
"J",
"K",
"L",
"M",
"N",
"O",
"P",
"Q",
"R",
"S",
"T",
"U",
"V",
"W",
"X",
"Y",
"Z",
"left-square-bracket",
"backslash",
"right-square-bracket",
"circumflex",
"underscore",
"grave-accent",
"a",
"b",
"c",
"d",
"e",
"f",
"g",
"h",
"i",
"j",
"k",
"l",
"m",
"n",
"o",
"p",
"q",
"r",
"s",
"t",
"u",
"v",
"w",
"x",
"y",
"z",
"left-curly-bracket",
"vertical-line",
"right-curly-bracket",
"tilde",
"DEL",
""
};
// same as boost
static const char* __digraphs[] =
{
"ae",
"Ae",
"AE",
"ch",
"Ch",
"CH",
"ll",
"Ll",
"LL",
"ss",
"Ss",
"SS",
"nj",
"Nj",
"NJ",
"dz",
"Dz",
"DZ",
"lj",
"Lj",
"LJ",
""
};
{
"ae",
"Ae",
"AE",
"ch",
"Ch",
"CH",
"ll",
"Ll",
"LL",
"ss",
"Ss",
"SS",
"nj",
"Nj",
"NJ",
"dz",
"Dz",
"DZ",
"lj",
"Lj",
"LJ",
""
};
std::string __s(__last - __first, '?');
__fctyp.narrow(__first, __last, '?', &*__s.begin());
for (unsigned int __i = 0; *__collatenames[__i]; __i++)
if (__s == __collatenames[__i])
return string_type(1, __fctyp.widen((char)__i));
if (__s == __collatenames[__i])
return string_type(1, __fctyp.widen((char)__i));
for (unsigned int __i = 0; *__digraphs[__i]; __i++)
{
const char* __now = __digraphs[__i];
if (__s == __now)
{
string_type ret(__s.size(), __fctyp.widen('?'));
__fctyp.widen(__now, __now + 2/* ouch */, &*ret.begin());
return ret;
}
}
{
const char* __now = __digraphs[__i];
if (__s == __now)
{
string_type ret(__s.size(), __fctyp.widen('?'));
__fctyp.widen(__now, __now + 2/* ouch */, &*ret.begin());
return ret;
}
}
return string_type();
}
......@@ -546,39 +546,39 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
static _ClassnameEntry __classnames[] =
{
{"d", ctype_base::digit},
{"w", {ctype_base::alnum, _RegexMask::_S_under}},
{"s", ctype_base::space},
{"alnum", ctype_base::alnum},
{"alpha", ctype_base::alpha},
{"blank", {0, _RegexMask::_S_blank}},
{"cntrl", ctype_base::cntrl},
{"digit", ctype_base::digit},
{"graph", ctype_base::graph},
{"lower", ctype_base::lower},
{"print", ctype_base::print},
{"punct", ctype_base::punct},
{"space", ctype_base::space},
{"upper", ctype_base::upper},
{"xdigit", ctype_base::xdigit},
{"d", ctype_base::digit},
{"w", {ctype_base::alnum, _RegexMask::_S_under}},
{"s", ctype_base::space},
{"alnum", ctype_base::alnum},
{"alpha", ctype_base::alpha},
{"blank", {0, _RegexMask::_S_blank}},
{"cntrl", ctype_base::cntrl},
{"digit", ctype_base::digit},
{"graph", ctype_base::graph},
{"lower", ctype_base::lower},
{"print", ctype_base::print},
{"punct", ctype_base::punct},
{"space", ctype_base::space},
{"upper", ctype_base::upper},
{"xdigit", ctype_base::xdigit},
};
std::string __s(__last - __first, '?');
__fctyp.narrow(__first, __last, '?', &__s[0]);
__cctyp.tolower(&*__s.begin(), &*__s.begin() + __s.size());
for (_ClassnameEntry* __it = __classnames;
__it < *(&__classnames + 1);
++__it)
{
if (__s == __it->first)
{
if (__icase
&& ((__it->second
& (ctype_base::lower | ctype_base::upper)) != 0))
return ctype_base::alpha;
return __it->second;
}
}
__it < *(&__classnames + 1);
++__it)
{
if (__s == __it->first)
{
if (__icase
&& ((__it->second
& (ctype_base::lower | ctype_base::upper)) != 0))
return ctype_base::alpha;
return __it->second;
}
}
return 0;
}
......@@ -591,13 +591,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
const __ctype_type& __fctyp(use_facet<__ctype_type>(_M_locale));
return __fctyp.is(__f._M_base, __c)
// [[:w:]]
|| ((__f._M_extended & _RegexMask::_S_under)
&& __c == __fctyp.widen('_'))
// [[:blank:]]
|| ((__f._M_extended & _RegexMask::_S_blank)
&& (__c == __fctyp.widen(' ')
|| __c == __fctyp.widen('\t')));
// [[:w:]]
|| ((__f._M_extended & _RegexMask::_S_under)
&& __c == __fctyp.widen('_'))
// [[:blank:]]
|| ((__f._M_extended & _RegexMask::_S_blank)
&& (__c == __fctyp.widen(' ')
|| __c == __fctyp.widen('\t')));
}
template<typename _Ch_type>
......@@ -689,7 +689,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* @throws regex_error if @p __p is not a valid regular expression.
*/
basic_regex(const _Ch_type* __p,
std::size_t __len, flag_type __f = ECMAScript)
std::size_t __len, flag_type __f = ECMAScript)
: basic_regex(__p, __p + __len, __f)
{ }
......@@ -707,7 +707,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
*/
basic_regex(const basic_regex&& __rhs) noexcept
: _M_flags(__rhs._M_flags), _M_traits(__rhs._M_traits),
_M_automaton(std::move(__rhs._M_automaton))
_M_automaton(std::move(__rhs._M_automaton))
{ }
/**
......@@ -720,12 +720,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* @throws regex_error if @p __s is not a valid regular expression.
*/
template<typename _Ch_traits, typename _Ch_alloc>
explicit
basic_regex(const std::basic_string<_Ch_type, _Ch_traits,
explicit
basic_regex(const std::basic_string<_Ch_type, _Ch_traits,
_Ch_alloc>& __s,
flag_type __f = ECMAScript)
: basic_regex(__s.begin(), __s.end(), __f)
{ }
{ }
/**
* @brief Constructs a basic regular expression from the range
......@@ -741,12 +741,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* expression.
*/
template<typename _InputIterator>
basic_regex(_InputIterator __first, _InputIterator __last,
basic_regex(_InputIterator __first, _InputIterator __last,
flag_type __f = ECMAScript)
: _M_flags(__f),
_M_automaton(__detail::_Compiler<_InputIterator, _Ch_type, _Rx_traits>
(__first, __last, _M_traits, _M_flags)._M_get_nfa())
{ }
_M_automaton(__detail::_Compiler<_InputIterator, _Ch_type, _Rx_traits>
(__first, __last, _M_traits, _M_flags)._M_get_nfa())
{ }
/**
* @brief Constructs a basic regular expression from an initializer list.
......@@ -799,9 +799,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* @param __s A pointer to a string containing a regular expression.
*/
template<typename _Ch_typeraits, typename _Alloc>
basic_regex&
operator=(const basic_string<_Ch_type, _Ch_typeraits, _Alloc>& __s)
{ return this->assign(__s, flags()); }
basic_regex&
operator=(const basic_string<_Ch_type, _Ch_typeraits, _Alloc>& __s)
{ return this->assign(__s, flags()); }
// [7.8.3] assign
/**
......@@ -876,10 +876,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* regex_error is thrown, *this remains unchanged.
*/
template<typename _Ch_typeraits, typename _Alloc>
basic_regex&
assign(const basic_string<_Ch_type, _Ch_typeraits, _Alloc>& __s,
basic_regex&
assign(const basic_string<_Ch_type, _Ch_typeraits, _Alloc>& __s,
flag_type __flags = ECMAScript)
{
{
basic_regex __tmp(__s, __flags);
this->swap(__tmp);
return *this;
......@@ -899,10 +899,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* regex_error is thrown, the object remains unchanged.
*/
template<typename _InputIterator>
basic_regex&
assign(_InputIterator __first, _InputIterator __last,
basic_regex&
assign(_InputIterator __first, _InputIterator __last,
flag_type __flags = ECMAScript)
{ return this->assign(string_type(__first, __last), __flags); }
{ return this->assign(string_type(__first, __last), __flags); }
/**
* @brief Assigns a new regular expression to a regex object.
......@@ -976,31 +976,31 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
protected:
typedef std::shared_ptr<__detail::_Automaton<_Ch_type, _Rx_traits>>
_AutomatonPtr;
_AutomatonPtr;
template<typename _BiIter, typename _Alloc,
typename _CharT, typename _TraitsT>
friend std::unique_ptr<
__detail::_Executor<_BiIter, _Alloc, _CharT, _TraitsT>>
__detail::__get_executor(_BiIter,
_BiIter,
match_results<_BiIter, _Alloc>&,
const basic_regex<_CharT, _TraitsT>&,
regex_constants::match_flag_type);
typename _CharT, typename _TraitsT>
friend std::unique_ptr<
__detail::_Executor<_BiIter, _Alloc, _CharT, _TraitsT>>
__detail::__get_executor(_BiIter,
_BiIter,
match_results<_BiIter, _Alloc>&,
const basic_regex<_CharT, _TraitsT>&,
regex_constants::match_flag_type);
template<typename _Bp, typename _Ap, typename _Cp, typename _Rp>
friend bool
regex_match(_Bp, _Bp,
match_results<_Bp, _Ap>&,
const basic_regex<_Cp, _Rp>&,
regex_constants::match_flag_type);
friend bool
regex_match(_Bp, _Bp,
match_results<_Bp, _Ap>&,
const basic_regex<_Cp, _Rp>&,
regex_constants::match_flag_type);
template<typename _Bp, typename _Ap, typename _Cp, typename _Rp>
friend bool
regex_search(_Bp, _Bp,
match_results<_Bp, _Ap>&,
const basic_regex<_Cp, _Rp>&,
regex_constants::match_flag_type);
friend bool
regex_search(_Bp, _Bp,
match_results<_Bp, _Ap>&,
const basic_regex<_Cp, _Rp>&,
regex_constants::match_flag_type);
flag_type _M_flags;
_Rx_traits _M_traits;
......@@ -1220,8 +1220,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// Alias for sub_match'd string.
template<typename _Bi_iter, typename _Ch_traits, typename _Ch_alloc>
using __sub_match_string = basic_string<
typename iterator_traits<_Bi_iter>::value_type,
_Ch_traits, _Ch_alloc>;
typename iterator_traits<_Bi_iter>::value_type,
_Ch_traits, _Ch_alloc>;
/**
* @brief Tests the equivalence of a string and a regular expression
......@@ -2019,50 +2019,50 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* @todo Implement this function.
*/
template<typename _Out_iter>
_Out_iter
format(_Out_iter __out, const char_type* __fmt_first,
_Out_iter
format(_Out_iter __out, const char_type* __fmt_first,
const char_type* __fmt_last,
match_flag_type __flags = regex_constants::format_default) const
{ return __out; }
{ return __out; }
/**
* @pre ready() == true
*/
template<typename _Out_iter, typename _St, typename _Sa>
_Out_iter
format(_Out_iter __out, const basic_string<char_type, _St, _Sa>& __fmt,
_Out_iter
format(_Out_iter __out, const basic_string<char_type, _St, _Sa>& __fmt,
match_flag_type __flags = regex_constants::format_default) const
{
return format(__out, __fmt.data(), __fmt.data() + __fmt.size(),
__flags);
}
{
return format(__out, __fmt.data(), __fmt.data() + __fmt.size(),
__flags);
}
/**
* @pre ready() == true
*/
template<typename _Out_iter, typename _St, typename _Sa>
basic_string<char_type, _St, _Sa>
format(const basic_string<char_type, _St, _Sa>& __fmt,
basic_string<char_type, _St, _Sa>
format(const basic_string<char_type, _St, _Sa>& __fmt,
match_flag_type __flags = regex_constants::format_default) const
{
basic_string<char_type, _St, _Sa> __result;
format(std::back_inserter(__result), __fmt, __flags);
return __result;
}
{
basic_string<char_type, _St, _Sa> __result;
format(std::back_inserter(__result), __fmt, __flags);
return __result;
}
/**
* @pre ready() == true
*/
string_type
format(const char_type* __fmt,
match_flag_type __flags = regex_constants::format_default) const
match_flag_type __flags = regex_constants::format_default) const
{
string_type __result;
format(std::back_inserter(__result),
__fmt,
__fmt + char_traits<char_type>::length(__fmt),
__flags);
return __result;
string_type __result;
format(std::back_inserter(__result),
__fmt,
__fmt + char_traits<char_type>::length(__fmt),
__flags);
return __result;
}
//@}
......@@ -2096,27 +2096,27 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
private:
template<typename, typename, typename, typename>
friend class __detail::_Executor;
friend class __detail::_Executor;
template<typename, typename, typename, typename>
friend class __detail::_DFSExecutor;
friend class __detail::_DFSExecutor;
template<typename, typename, typename, typename>
friend class __detail::_BFSExecutor;
friend class __detail::_BFSExecutor;
template<typename _Bp, typename _Ap, typename _Ch_type, typename _Rx_traits>
friend bool
regex_match(_Bp, _Bp, match_results<_Bp, _Ap>&,
const basic_regex<_Ch_type,
_Rx_traits>&,
regex_constants::match_flag_type);
friend bool
regex_match(_Bp, _Bp, match_results<_Bp, _Ap>&,
const basic_regex<_Ch_type,
_Rx_traits>&,
regex_constants::match_flag_type);
template<typename _Bp, typename _Ap, typename _Ch_type, typename _Rx_traits>
friend bool
regex_search(_Bp, _Bp, match_results<_Bp, _Ap>&,
const basic_regex<_Ch_type,
_Rx_traits>&,
regex_constants::match_flag_type);
friend bool
regex_search(_Bp, _Bp, match_results<_Bp, _Ap>&,
const basic_regex<_Ch_type,
_Rx_traits>&,
regex_constants::match_flag_type);
};
typedef match_results<const char*> cmatch;
......@@ -2138,17 +2138,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
const match_results<_Bi_iter, _Alloc>& __m2)
{
if (__m1.ready() != __m2.ready())
return false;
return false;
if (!__m1.ready()) // both are not ready
return true;
return true;
if (__m1.empty() != __m2.empty())
return false;
return false;
if (__m1.empty()) // both are empty
return true;
return true;
return __m1.prefix() == __m2.prefix()
&& __m1.size() == __m2.size()
&& std::equal(__m1.begin(), __m1.end(), __m2.begin())
&& __m1.suffix() == __m2.suffix();
&& __m1.size() == __m2.size()
&& std::equal(__m1.begin(), __m1.end(), __m2.begin())
&& __m1.suffix() == __m2.suffix();
}
/**
......@@ -2203,28 +2203,28 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
typename _Ch_type, typename _Rx_traits>
bool
regex_match(_Bi_iter __s,
_Bi_iter __e,
match_results<_Bi_iter, _Alloc>& __m,
const basic_regex<_Ch_type, _Rx_traits>& __re,
regex_constants::match_flag_type __flags
= regex_constants::match_default)
_Bi_iter __e,
match_results<_Bi_iter, _Alloc>& __m,
const basic_regex<_Ch_type, _Rx_traits>& __re,
regex_constants::match_flag_type __flags
= regex_constants::match_default)
{
if (__re._M_automaton == nullptr)
return false;
return false;
__detail::__get_executor(__s, __e, __m, __re, __flags)->_M_match();
if (__m.size() > 0 && __m[0].matched)
{
for (auto __it : __m)
if (!__it.matched)
__it.first = __it.second = __e;
__m.at(__m.size()).matched = false;
__m.at(__m.size()).first = __s;
__m.at(__m.size()).second = __s;
__m.at(__m.size()+1).matched = false;
__m.at(__m.size()+1).first = __e;
__m.at(__m.size()+1).second = __e;
return true;
}
{
for (auto __it : __m)
if (!__it.matched)
__it.first = __it.second = __e;
__m.at(__m.size()).matched = false;
__m.at(__m.size()).first = __s;
__m.at(__m.size()).second = __s;
__m.at(__m.size()+1).matched = false;
__m.at(__m.size()+1).first = __e;
__m.at(__m.size()+1).second = __e;
return true;
}
return false;
}
......@@ -2364,18 +2364,18 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
typename _Ch_type, typename _Rx_traits>
inline bool
regex_search(_Bi_iter __first, _Bi_iter __last,
match_results<_Bi_iter, _Alloc>& __m,
const basic_regex<_Ch_type, _Rx_traits>& __re,
regex_constants::match_flag_type __flags
= regex_constants::match_default)
match_results<_Bi_iter, _Alloc>& __m,
const basic_regex<_Ch_type, _Rx_traits>& __re,
regex_constants::match_flag_type __flags
= regex_constants::match_default)
{
if (__re._M_automaton == nullptr)
return false;
return false;
for (auto __cur = __first; __cur != __last; ++__cur) // Any KMP-like algo?
{
__detail::__get_executor(__cur, __last, __m, __re, __flags)
->_M_search_from_first();
if (__m.size() > 0 && __m[0].matched)
{
__detail::__get_executor(__cur, __last, __m, __re, __flags)
->_M_search_from_first();
if (__m.size() > 0 && __m[0].matched)
{
for (auto __it : __m)
if (!__it.matched)
......@@ -2390,7 +2390,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
(__m.suffix().first != __m.suffix().second);
return true;
}
}
}
return false;
}
......@@ -2641,9 +2641,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
regex_iterator
operator++(int)
{
auto __tmp = *this;
++(*this);
return __tmp;
auto __tmp = *this;
++(*this);
return __tmp;
}
private:
......@@ -2662,11 +2662,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
operator==(const regex_iterator& __rhs) const
{
return (_M_match.empty() && __rhs._M_match.empty())
|| (_M_begin == __rhs._M_begin
&& _M_end == __rhs._M_end
&& _M_pregex == __rhs._M_pregex
&& _M_flags == __rhs._M_flags
&& _M_match[0] == __rhs._M_match[0]);
|| (_M_begin == __rhs._M_begin
&& _M_end == __rhs._M_end
&& _M_pregex == __rhs._M_pregex
&& _M_flags == __rhs._M_flags
&& _M_match[0] == __rhs._M_match[0]);
}
template<typename _Bi_iter,
......@@ -2683,27 +2683,27 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// match[i].position() shall return distance(begin, match[i].first).
// [28.12.1.4.5]
if (_M_match[0].matched)
{
auto __start = _M_match[0].second;
if (_M_match[0].first == _M_match[0].second)
if (__start == _M_end)
{
_M_match = value_type();
return *this;
}
else
{
if (regex_search(__start, _M_end, _M_match, *_M_pregex, _M_flags
| regex_constants::match_not_null
| regex_constants::match_continuous))
return *this;
else
++__start;
}
_M_flags |= regex_constants::match_prev_avail;
if (!regex_search(__start, _M_end, _M_match, *_M_pregex, _M_flags))
_M_match = value_type();
}
{
auto __start = _M_match[0].second;
if (_M_match[0].first == _M_match[0].second)
if (__start == _M_end)
{
_M_match = value_type();
return *this;
}
else
{
if (regex_search(__start, _M_end, _M_match, *_M_pregex, _M_flags
| regex_constants::match_not_null
| regex_constants::match_continuous))
return *this;
else
++__start;
}
_M_flags |= regex_constants::match_prev_avail;
if (!regex_search(__start, _M_end, _M_match, *_M_pregex, _M_flags))
_M_match = value_type();
}
return *this;
}
......@@ -2723,8 +2723,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* value of an iterator of this class is a std::sub_match object.
*/
template<typename _Bi_iter,
typename _Ch_type = typename iterator_traits<_Bi_iter>::value_type,
typename _Rx_traits = regex_traits<_Ch_type> >
typename _Ch_type = typename iterator_traits<_Bi_iter>::value_type,
typename _Rx_traits = regex_traits<_Ch_type> >
class regex_token_iterator
{
public:
......@@ -2799,7 +2799,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
*/
regex_token_iterator(_Bi_iter __a, _Bi_iter __b,
const regex_type& __re,
initializer_list<int> __submatches,
initializer_list<int> __submatches,
regex_constants::match_flag_type __m
= regex_constants::match_default)
: _M_position(__a, __b, __re, __m), _M_subs(__submatches), _M_n(0)
......@@ -2815,7 +2815,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
* @param __m [IN] Policy flags for match rules.
*/
template<std::size_t _Nm>
regex_token_iterator(_Bi_iter __a, _Bi_iter __b,
regex_token_iterator(_Bi_iter __a, _Bi_iter __b,
const regex_type& __re,
const int (&__submatches)[_Nm],
regex_constants::match_flag_type __m
......@@ -2833,8 +2833,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_M_result(__rhs.result), _M_suffix(__rhs.suffix),
_M_has_m1(__rhs._M_has_m1)
{
if (__rhs._M_result == &__rhs._M_suffix)
_M_result = &_M_suffix;
if (__rhs._M_result == &__rhs._M_suffix)
_M_result = &_M_suffix;
}
/**
......@@ -2883,9 +2883,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
regex_token_iterator
operator++(int)
{
auto __tmp = *this;
++(*this);
return __tmp;
auto __tmp = *this;
++(*this);
return __tmp;
}
private:
......@@ -2897,10 +2897,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
const value_type&
_M_current_match() const
{
if (_M_subs[_M_n] == -1)
return (*_M_position).prefix();
else
return (*_M_position)[_M_subs[_M_n]];
if (_M_subs[_M_n] == -1)
return (*_M_position).prefix();
else
return (*_M_position)[_M_subs[_M_n]];
}
bool
......@@ -2918,8 +2918,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
};
template<typename _Bi_iter,
typename _Ch_type,
typename _Rx_traits>
typename _Ch_type,
typename _Rx_traits>
regex_token_iterator<_Bi_iter, _Ch_type, _Rx_traits>&
regex_token_iterator<_Bi_iter, _Ch_type, _Rx_traits>::
operator=(const regex_token_iterator& __rhs)
......@@ -2931,88 +2931,88 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_M_suffix = __rhs._M_suffix;
_M_has_m1 = __rhs._M_has_m1;
if (__rhs._M_result == &__rhs._M_suffix)
_M_result = &_M_suffix;
_M_result = &_M_suffix;
}
template<typename _Bi_iter,
typename _Ch_type,
typename _Rx_traits>
typename _Ch_type,
typename _Rx_traits>
bool
regex_token_iterator<_Bi_iter, _Ch_type, _Rx_traits>::
operator==(const regex_token_iterator& __rhs) const
{
if (_M_end_of_seq() && __rhs._M_end_of_seq())
return true;
return true;
if (_M_suffix.matched && __rhs._M_suffix.matched
&& _M_suffix == __rhs._M_suffix)
return true;
&& _M_suffix == __rhs._M_suffix)
return true;
if (_M_end_of_seq() || _M_suffix.matched
|| __rhs._M_end_of_seq() || __rhs._M_suffix.matched)
return false;
|| __rhs._M_end_of_seq() || __rhs._M_suffix.matched)
return false;
return _M_position == __rhs._M_position
&& _M_n == __rhs._M_n
&& _M_subs == __rhs._M_subs;
&& _M_n == __rhs._M_n
&& _M_subs == __rhs._M_subs;
}
template<typename _Bi_iter,
typename _Ch_type,
typename _Rx_traits>
typename _Ch_type,
typename _Rx_traits>
regex_token_iterator<_Bi_iter, _Ch_type, _Rx_traits>&
regex_token_iterator<_Bi_iter, _Ch_type, _Rx_traits>::
operator++()
{
_Position __prev = _M_position;
if (_M_suffix.matched)
*this = regex_token_iterator();
*this = regex_token_iterator();
else if (_M_n + 1 < _M_subs.size())
{
_M_n++;
_M_result = &_M_current_match();
}
{
_M_n++;
_M_result = &_M_current_match();
}
else
{
_M_n = 0;
++_M_position;
if (_M_position != _Position())
_M_result = &_M_current_match();
else if (_M_has_m1 && __prev->suffix().length() != 0)
{
_M_suffix.matched = true;
_M_suffix.first = __prev->suffix().first;
_M_suffix.second = __prev->suffix().second;
_M_result = &_M_suffix;
}
else
*this = regex_token_iterator();
}
{
_M_n = 0;
++_M_position;
if (_M_position != _Position())
_M_result = &_M_current_match();
else if (_M_has_m1 && __prev->suffix().length() != 0)
{
_M_suffix.matched = true;
_M_suffix.first = __prev->suffix().first;
_M_suffix.second = __prev->suffix().second;
_M_result = &_M_suffix;
}
else
*this = regex_token_iterator();
}
return *this;
}
template<typename _Bi_iter,
typename _Ch_type,
typename _Rx_traits>
typename _Ch_type,
typename _Rx_traits>
void
regex_token_iterator<_Bi_iter, _Ch_type, _Rx_traits>::
_M_init(_Bi_iter __a, _Bi_iter __b)
{
_M_has_m1 = false;
for (auto __it : _M_subs)
if (__it == -1)
{
_M_has_m1 = true;
break;
}
if (__it == -1)
{
_M_has_m1 = true;
break;
}
if (_M_position != _Position())
_M_result = &_M_current_match();
_M_result = &_M_current_match();
else if (_M_has_m1)
{
_M_suffix.matched = true;
_M_suffix.first = __a;
_M_suffix.second = __b;
_M_result = &_M_suffix;
}
{
_M_suffix.matched = true;
_M_suffix.first = __a;
_M_suffix.second = __b;
_M_result = &_M_suffix;
}
else
_M_result = nullptr;
_M_result = nullptr;
}
/** @brief Token iterator for C-style NULL-terminated strings. */
......
......@@ -71,9 +71,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_StateIdT _M_next; // outgoing transition
union // Since they are mutual exclusive.
{
_StateIdT _M_alt; // for _S_opcode_alternative
unsigned int _M_subexpr; // for _S_opcode_subexpr_*
unsigned int _M_backref_index; // for _S_opcode_backref
_StateIdT _M_alt; // for _S_opcode_alternative
unsigned int _M_subexpr; // for _S_opcode_subexpr_*
unsigned int _M_backref_index; // for _S_opcode_backref
};
_MatcherT _M_matches; // for _S_opcode_match
......@@ -83,17 +83,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_State(const _MatcherT& __m)
: _M_opcode(_S_opcode_match), _M_next(_S_invalid_state_id),
_M_matches(__m)
_M_matches(__m)
{ }
_State(_OpcodeT __opcode, unsigned __index)
: _M_opcode(__opcode), _M_next(_S_invalid_state_id)
{
if (__opcode == _S_opcode_subexpr_begin
|| __opcode == _S_opcode_subexpr_end)
_M_subexpr = __index;
else if (__opcode == _S_opcode_backref)
_M_backref_index = __index;
if (__opcode == _S_opcode_subexpr_begin
|| __opcode == _S_opcode_subexpr_end)
_M_subexpr = __index;
else if (__opcode == _S_opcode_backref)
_M_backref_index = __index;
}
_State(_StateIdT __next, _StateIdT __alt)
......@@ -162,40 +162,40 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_StateIdT
_M_insert_accept()
{
this->push_back(_StateT(_S_opcode_accept));
_M_accepting_states.insert(this->size()-1);
return this->size()-1;
this->push_back(_StateT(_S_opcode_accept));
_M_accepting_states.insert(this->size()-1);
return this->size()-1;
}
_StateIdT
_M_insert_alt(_StateIdT __next, _StateIdT __alt)
{
this->push_back(_StateT(__next, __alt));
return this->size()-1;
this->push_back(_StateT(__next, __alt));
return this->size()-1;
}
_StateIdT
_M_insert_matcher(_MatcherT __m)
{
this->push_back(_StateT(__m));
return this->size()-1;
this->push_back(_StateT(__m));
return this->size()-1;
}
_StateIdT
_M_insert_subexpr_begin()
{
auto __id = _M_subexpr_count++;
_M_paren_stack.push_back(__id);
this->push_back(_StateT(_S_opcode_subexpr_begin, __id));
return this->size()-1;
auto __id = _M_subexpr_count++;
_M_paren_stack.push_back(__id);
this->push_back(_StateT(_S_opcode_subexpr_begin, __id));
return this->size()-1;
}
_StateIdT
_M_insert_subexpr_end()
{
this->push_back(_StateT(_S_opcode_subexpr_end, _M_paren_stack.back()));
_M_paren_stack.pop_back();
return this->size()-1;
this->push_back(_StateT(_S_opcode_subexpr_end, _M_paren_stack.back()));
_M_paren_stack.pop_back();
return this->size()-1;
}
_StateIdT
......@@ -225,27 +225,27 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
public:
// Constructs a single-node sequence
_StateSeq(_RegexT& __ss, _StateIdT __s,
_StateIdT __e = _S_invalid_state_id)
_StateIdT __e = _S_invalid_state_id)
: _M_nfa(__ss), _M_start(__s), _M_end1(__s), _M_end2(__e)
{ }
// Constructs a split sequence from two other sequencces
_StateSeq(const _StateSeq& __e1, const _StateSeq& __e2)
: _M_nfa(__e1._M_nfa),
_M_start(_M_nfa._M_insert_alt(__e1._M_start, __e2._M_start)),
_M_end1(__e1._M_end1), _M_end2(__e2._M_end1)
_M_start(_M_nfa._M_insert_alt(__e1._M_start, __e2._M_start)),
_M_end1(__e1._M_end1), _M_end2(__e2._M_end1)
{ }
// Constructs a split sequence from a single sequence
_StateSeq(const _StateSeq& __e, _StateIdT __id)
: _M_nfa(__e._M_nfa),
_M_start(_M_nfa._M_insert_alt(__id, __e._M_start)),
_M_end1(__id), _M_end2(__e._M_end1)
_M_start(_M_nfa._M_insert_alt(__id, __e._M_start)),
_M_end1(__id), _M_end2(__e._M_end1)
{ }
// Constructs a copy of a %_StateSeq
_StateSeq(const _StateSeq& __rhs)
: _M_nfa(__rhs._M_nfa), _M_start(__rhs._M_start),
_M_end1(__rhs._M_end1), _M_end2(__rhs._M_end2)
_M_end1(__rhs._M_end1), _M_end2(__rhs._M_end2)
{ }
_StateSeq& operator=(const _StateSeq& __rhs);
......
......@@ -41,27 +41,27 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{
switch (_M_opcode)
{
case _S_opcode_alternative:
ostr << "alt next=" << _M_next << " alt=" << _M_alt;
break;
case _S_opcode_subexpr_begin:
ostr << "subexpr begin next=" << _M_next << " index=" << _M_subexpr;
break;
case _S_opcode_subexpr_end:
ostr << "subexpr end next=" << _M_next << " index=" << _M_subexpr;
break;
case _S_opcode_backref:
ostr << "backref next=" << _M_next << " index=" << _M_backref_index;
break;
case _S_opcode_match:
ostr << "match next=" << _M_next;
break;
case _S_opcode_accept:
ostr << "accept next=" << _M_next;
break;
default:
ostr << "unknown next=" << _M_next;
break;
case _S_opcode_alternative:
ostr << "alt next=" << _M_next << " alt=" << _M_alt;
break;
case _S_opcode_subexpr_begin:
ostr << "subexpr begin next=" << _M_next << " index=" << _M_subexpr;
break;
case _S_opcode_subexpr_end:
ostr << "subexpr end next=" << _M_next << " index=" << _M_subexpr;
break;
case _S_opcode_backref:
ostr << "backref next=" << _M_next << " index=" << _M_backref_index;
break;
case _S_opcode_match:
ostr << "match next=" << _M_next;
break;
case _S_opcode_accept:
ostr << "accept next=" << _M_next;
break;
default:
ostr << "unknown next=" << _M_next;
break;
}
return ostr;
}
......@@ -73,39 +73,39 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{
switch (_M_opcode)
{
case _S_opcode_alternative:
__ostr << __id << " [label=\"" << __id << "\\nALT\"];\n"
<< __id << " -> " << _M_next
<< " [label=\"epsilon\", tailport=\"s\"];\n"
<< __id << " -> " << _M_alt
<< " [label=\"epsilon\", tailport=\"n\"];\n";
break;
case _S_opcode_subexpr_begin:
__ostr << __id << " [label=\"" << __id << "\\nSBEGIN "
<< _M_subexpr << "\"];\n"
<< __id << " -> " << _M_next << " [label=\"epsilon\"];\n";
break;
case _S_opcode_subexpr_end:
__ostr << __id << " [label=\"" << __id << "\\nSEND "
<< _M_subexpr << "\"];\n"
<< __id << " -> " << _M_next << " [label=\"epsilon\"];\n";
break;
case _S_opcode_backref:
__ostr << __id << " [label=\"" << __id << "\\nBACKREF "
<< _M_subexpr << "\"];\n"
<< __id << " -> " << _M_next << " [label=\"<match>\"];\n";
break;
case _S_opcode_match:
__ostr << __id << " [label=\"" << __id << "\\nMATCH\"];\n"
<< __id << " -> " << _M_next << " [label=\"<match>\"];\n";
break;
case _S_opcode_accept:
__ostr << __id << " [label=\"" << __id << "\\nACC\"];\n" ;
break;
default:
__ostr << __id << " [label=\"" << __id << "\\nUNK\"];\n"
<< __id << " -> " << _M_next << " [label=\"?\"];\n";
break;
case _S_opcode_alternative:
__ostr << __id << " [label=\"" << __id << "\\nALT\"];\n"
<< __id << " -> " << _M_next
<< " [label=\"epsilon\", tailport=\"s\"];\n"
<< __id << " -> " << _M_alt
<< " [label=\"epsilon\", tailport=\"n\"];\n";
break;
case _S_opcode_subexpr_begin:
__ostr << __id << " [label=\"" << __id << "\\nSBEGIN "
<< _M_subexpr << "\"];\n"
<< __id << " -> " << _M_next << " [label=\"epsilon\"];\n";
break;
case _S_opcode_subexpr_end:
__ostr << __id << " [label=\"" << __id << "\\nSEND "
<< _M_subexpr << "\"];\n"
<< __id << " -> " << _M_next << " [label=\"epsilon\"];\n";
break;
case _S_opcode_backref:
__ostr << __id << " [label=\"" << __id << "\\nBACKREF "
<< _M_subexpr << "\"];\n"
<< __id << " -> " << _M_next << " [label=\"<match>\"];\n";
break;
case _S_opcode_match:
__ostr << __id << " [label=\"" << __id << "\\nMATCH\"];\n"
<< __id << " -> " << _M_next << " [label=\"<match>\"];\n";
break;
case _S_opcode_accept:
__ostr << __id << " [label=\"" << __id << "\\nACC\"];\n" ;
break;
default:
__ostr << __id << " [label=\"" << __id << "\\nUNK\"];\n"
<< __id << " -> " << _M_next << " [label=\"?\"];\n";
break;
}
return __ostr;
}
......@@ -135,10 +135,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// _M_paren_stack is {1, 3}, for incomplete "(a.." and "(c..". At this
// time, "\\2" is valid, but "\\1" and "\\3" are not.
if (__index >= _M_subexpr_count)
__throw_regex_error(regex_constants::error_backref);
__throw_regex_error(regex_constants::error_backref);
for (auto __it : _M_paren_stack)
if (__index == __it)
__throw_regex_error(regex_constants::error_backref);
if (__index == __it)
__throw_regex_error(regex_constants::error_backref);
_M_has_backref = true;
this->push_back(_StateT(_S_opcode_backref, __index));
return this->size()-1;
......@@ -159,7 +159,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_M_push_back(_StateIdT __id)
{
if (_M_end1 != _S_invalid_state_id)
_M_nfa[_M_end1]._M_next = __id;
_M_nfa[_M_end1]._M_next = __id;
_M_end1 = __id;
}
......@@ -169,14 +169,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{
if (_M_end2 != _S_invalid_state_id)
{
if (_M_end2 == _M_end1)
_M_nfa[_M_end2]._M_alt = __id;
else
_M_nfa[_M_end2]._M_next = __id;
_M_end2 = _S_invalid_state_id;
if (_M_end2 == _M_end1)
_M_nfa[_M_end2]._M_alt = __id;
else
_M_nfa[_M_end2]._M_next = __id;
_M_end2 = _S_invalid_state_id;
}
if (_M_end1 != _S_invalid_state_id)
_M_nfa[_M_end1]._M_next = __id;
_M_nfa[_M_end1]._M_next = __id;
_M_end1 = __id;
}
......@@ -186,16 +186,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{
if (_M_end2 != _S_invalid_state_id)
{
if (_M_end2 == _M_end1)
_M_nfa[_M_end2]._M_alt = __rhs._M_start;
else
_M_nfa[_M_end2]._M_next = __rhs._M_start;
_M_end2 = _S_invalid_state_id;
if (_M_end2 == _M_end1)
_M_nfa[_M_end2]._M_alt = __rhs._M_start;
else
_M_nfa[_M_end2]._M_next = __rhs._M_start;
_M_end2 = _S_invalid_state_id;
}
if (__rhs._M_end2 != _S_invalid_state_id)
_M_end2 = __rhs._M_end2;
_M_end2 = __rhs._M_end2;
if (_M_end1 != _S_invalid_state_id)
_M_nfa[_M_end1]._M_next = __rhs._M_start;
_M_nfa[_M_end1]._M_next = __rhs._M_start;
_M_end1 = __rhs._M_end1;
}
......
......@@ -49,10 +49,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
explicit
_BracketMatcher(bool __is_non_matching,
const _TraitsT& __t,
_FlagT __flags)
const _TraitsT& __t,
_FlagT __flags)
: _M_is_non_matching(__is_non_matching), _M_traits(__t),
_M_flags(__flags), _M_class_set(0)
_M_flags(__flags), _M_class_set(0)
{ }
bool
......@@ -61,40 +61,40 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
void
_M_add_char(_CharT __c)
{
if (_M_flags & regex_constants::collate)
if (_M_is_icase())
_M_char_set.push_back(_M_traits.translate_nocase(__c));
else
_M_char_set.push_back(_M_traits.translate(__c));
else
_M_char_set.push_back(__c);
if (_M_flags & regex_constants::collate)
if (_M_is_icase())
_M_char_set.push_back(_M_traits.translate_nocase(__c));
else
_M_char_set.push_back(_M_traits.translate(__c));
else
_M_char_set.push_back(__c);
}
void
_M_add_collating_element(const _StringT& __s)
{
auto __st = _M_traits.lookup_collatename(&*__s.begin(), &*__s.end());
if (__st.empty())
__throw_regex_error(regex_constants::error_collate);
// TODO: digraph
_M_char_set.push_back(__st[0]);
auto __st = _M_traits.lookup_collatename(&*__s.begin(), &*__s.end());
if (__st.empty())
__throw_regex_error(regex_constants::error_collate);
// TODO: digraph
_M_char_set.push_back(__st[0]);
}
void
_M_add_equivalence_class(const _StringT& __s)
{
_M_add_character_class(
_M_traits.transform_primary(&*__s.begin(), &*__s.end()));
_M_add_character_class(
_M_traits.transform_primary(&*__s.begin(), &*__s.end()));
}
void
_M_add_character_class(const _StringT& __s)
{
auto __st = _M_traits.
lookup_classname(&*__s.begin(), &*__s.end(), _M_is_icase());
if (__st == 0)
__throw_regex_error(regex_constants::error_ctype);
_M_class_set |= __st;
auto __st = _M_traits.
lookup_classname(&*__s.begin(), &*__s.end(), _M_is_icase());
if (__st == 0)
__throw_regex_error(regex_constants::error_ctype);
_M_class_set |= __st;
}
void
......@@ -108,11 +108,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_StringT
_M_get_str(_CharT __c) const
{
auto __s = _StringT(1,
_M_is_icase()
? _M_traits.translate_nocase(__c)
: _M_traits.translate(__c));
return _M_traits.transform(__s.begin(), __s.end());
auto __s = _StringT(1,
_M_is_icase()
? _M_traits.translate_nocase(__c)
: _M_traits.translate(__c));
return _M_traits.transform(__s.begin(), __s.end());
}
_TraitsT _M_traits;
......@@ -177,9 +177,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
};
_Scanner(_InputIter __begin, _InputIter __end,
_FlagT __flags, std::locale __loc)
_FlagT __flags, std::locale __loc)
: _M_current(__begin) , _M_end(__end) , _M_flags(__flags),
_M_ctype(std::use_facet<_CtypeT>(__loc)), _M_state(0)
_M_ctype(std::use_facet<_CtypeT>(__loc)), _M_state(0)
{ _M_advance(); }
void
......@@ -238,7 +238,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
typedef regex_constants::syntax_option_type _FlagT;
_Compiler(_InputIter __b, _InputIter __e,
const _TraitsT& __traits, _FlagT __flags);
const _TraitsT& __traits, _FlagT __flags);
std::shared_ptr<_RegexT>
_M_get_nfa() const
......
......@@ -98,13 +98,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
else if (__c == _M_ctype.widen('['))
{
if (*++_M_current == _M_ctype.widen('^'))
{
_M_curToken = _S_token_bracket_inverse_begin;
++_M_current;
}
else
_M_curToken = _S_token_bracket_begin;
if (*++_M_current == _M_ctype.widen('^'))
{
_M_curToken = _S_token_bracket_inverse_begin;
++_M_current;
}
else
_M_curToken = _S_token_bracket_begin;
_M_state |= _S_state_in_bracket;
return;
}
......@@ -223,16 +223,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
else if (*_M_current == _M_ctype.widen(']'))
{
_M_curToken = _S_token_bracket_end;
_M_state &= ~_S_state_in_bracket;
++_M_current;
return;
_M_curToken = _S_token_bracket_end;
_M_state &= ~_S_state_in_bracket;
++_M_current;
return;
}
else if (*_M_current == _M_ctype.widen('\\'))
{
{
_M_eat_escape();
return;
}
}
_M_curToken = _S_token_collelem_single;
_M_curValue.assign(1, *_M_current);
++_M_current;
......@@ -341,23 +341,23 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_M_curValue.assign(1, __c);
}
else if (_M_state & _S_state_in_bracket)
{
if (__c == _M_ctype.widen('-')
|| __c == _M_ctype.widen('[')
|| __c == _M_ctype.widen(']'))
{
_M_curToken = _S_token_ord_char;
_M_curValue.assign(1, __c);
}
else if ((_M_flags & regex_constants::ECMAScript)
&& __c == _M_ctype.widen('b'))
{
_M_curToken = _S_token_ord_char;
_M_curValue.assign(1, _M_ctype.widen(' '));
}
else
__throw_regex_error(regex_constants::error_escape);
}
{
if (__c == _M_ctype.widen('-')
|| __c == _M_ctype.widen('[')
|| __c == _M_ctype.widen(']'))
{
_M_curToken = _S_token_ord_char;
_M_curValue.assign(1, __c);
}
else if ((_M_flags & regex_constants::ECMAScript)
&& __c == _M_ctype.widen('b'))
{
_M_curToken = _S_token_ord_char;
_M_curValue.assign(1, _M_ctype.widen(' '));
}
else
__throw_regex_error(regex_constants::error_escape);
}
else
__throw_regex_error(regex_constants::error_escape);
}
......@@ -444,8 +444,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
ostr << "bracket-begin\n";
break;
case _S_token_bracket_inverse_begin:
ostr << "bracket-inverse-begin\n";
break;
ostr << "bracket-inverse-begin\n";
break;
case _S_token_bracket_end:
ostr << "bracket-end\n";
break;
......@@ -518,8 +518,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
case _S_token_unknown:
ostr << "-- unknown token --\n";
break;
default:
_GLIBCXX_DEBUG_ASSERT(false);
default:
_GLIBCXX_DEBUG_ASSERT(false);
}
return ostr;
}
......@@ -528,7 +528,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _InputIter, typename _CharT, typename _TraitsT>
_Compiler<_InputIter, _CharT, _TraitsT>::
_Compiler(_InputIter __b, _InputIter __e,
const _TraitsT& __traits, _FlagT __flags)
const _TraitsT& __traits, _FlagT __flags)
: _M_traits(__traits), _M_scanner(__b, __e, __flags, _M_traits.getloc()),
_M_state_store(__flags), _M_flags(__flags)
{
......@@ -551,8 +551,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{
if (token == _M_scanner._M_token())
{
_M_cur_value = _M_scanner._M_value();
_M_scanner._M_advance();
_M_cur_value = _M_scanner._M_value();
_M_scanner._M_advance();
return true;
}
return false;
......@@ -714,39 +714,39 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{
if (_M_match_token(_ScannerT::_S_token_anychar))
{
const static auto&
__any_matcher = [](_CharT) -> bool
{ return true; };
const static auto&
__any_matcher = [](_CharT) -> bool
{ return true; };
_M_stack.push(_StateSeqT(_M_state_store,
_M_state_store._M_insert_matcher
(__any_matcher)));
_M_state_store._M_insert_matcher
(__any_matcher)));
return true;
}
if (_M_match_token(_ScannerT::_S_token_ord_char))
{
auto __c = _M_cur_value[0];
__detail::_Matcher<_CharT> f;
if (_M_flags & regex_constants::icase)
{
auto __traits = this->_M_traits;
__c = __traits.translate_nocase(__c);
f = [__traits, __c](_CharT __ch) -> bool
{ return __traits.translate_nocase(__ch) == __c; };
}
else
f = [__c](_CharT __ch) -> bool
{ return __ch == __c; };
auto __c = _M_cur_value[0];
__detail::_Matcher<_CharT> f;
if (_M_flags & regex_constants::icase)
{
auto __traits = this->_M_traits;
__c = __traits.translate_nocase(__c);
f = [__traits, __c](_CharT __ch) -> bool
{ return __traits.translate_nocase(__ch) == __c; };
}
else
f = [__c](_CharT __ch) -> bool
{ return __ch == __c; };
_M_stack.push(_StateSeqT(_M_state_store,
_M_state_store._M_insert_matcher(f)));
_M_state_store._M_insert_matcher(f)));
return true;
}
if (_M_match_token(_ScannerT::_S_token_backref))
{
// __m.push(_Matcher::_S_opcode_ordchar, _M_cur_value);
_M_stack.push(_StateSeqT(_M_state_store, _M_state_store.
_M_insert_backref(_M_cur_int_value(10))));
_M_insert_backref(_M_cur_int_value(10))));
return true;
}
if (_M_match_token(_ScannerT::_S_token_subexpr_begin))
......@@ -776,17 +776,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_M_bracket_expression()
{
bool __inverse =
_M_match_token(_ScannerT::_S_token_bracket_inverse_begin);
_M_match_token(_ScannerT::_S_token_bracket_inverse_begin);
if (!(__inverse || _M_match_token(_ScannerT::_S_token_bracket_begin)))
return false;
return false;
_BMatcherT __matcher( __inverse, _M_traits, _M_flags);
// special case: only if _not_ chr first after
// '[' or '[^' or if ECMAscript
if (!_M_bracket_list(__matcher) // list is empty
&& !(_M_flags & regex_constants::ECMAScript))
__throw_regex_error(regex_constants::error_brack);
&& !(_M_flags & regex_constants::ECMAScript))
__throw_regex_error(regex_constants::error_brack);
_M_stack.push(_StateSeqT(_M_state_store,
_M_state_store._M_insert_matcher(__matcher)));
_M_state_store._M_insert_matcher(__matcher)));
return true;
}
......@@ -796,7 +796,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_M_bracket_list(_BMatcherT& __matcher)
{
if (_M_match_token(_ScannerT::_S_token_bracket_end))
return false;
return false;
_M_expression_term(__matcher);
_M_bracket_list(__matcher);
return true;
......@@ -823,25 +823,25 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
return;
}
if (_M_match_token(_ScannerT::_S_token_collelem_single)) // [a
{
auto __ch = _M_cur_value[0];
if (_M_match_token(_ScannerT::_S_token_dash)) // [a-
{
// If the dash is the last character in the bracket expression,
// it is not special.
if (_M_scanner._M_token() == _ScannerT::_S_token_bracket_end)
__matcher._M_add_char(_M_cur_value[0]); // [a-] <=> [a\-]
else // [a-z]
{
if (!_M_match_token(_ScannerT::_S_token_collelem_single))
__throw_regex_error(regex_constants::error_range);
__matcher._M_make_range(__ch, _M_cur_value[0]);
}
}
else // [a]
__matcher._M_add_char(__ch);
return;
}
{
auto __ch = _M_cur_value[0];
if (_M_match_token(_ScannerT::_S_token_dash)) // [a-
{
// If the dash is the last character in the bracket expression,
// it is not special.
if (_M_scanner._M_token() == _ScannerT::_S_token_bracket_end)
__matcher._M_add_char(_M_cur_value[0]); // [a-] <=> [a\-]
else // [a-z]
{
if (!_M_match_token(_ScannerT::_S_token_collelem_single))
__throw_regex_error(regex_constants::error_range);
__matcher._M_make_range(__ch, _M_cur_value[0]);
}
}
else // [a]
__matcher._M_add_char(__ch);
return;
}
__throw_regex_error(regex_constants::error_brack);
}
......@@ -863,32 +863,32 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{
auto __oldch = __ch;
if (_M_flags & regex_constants::collate)
if (_M_is_icase())
__ch = _M_traits.translate_nocase(__ch);
else
__ch = _M_traits.translate(__ch);
if (_M_is_icase())
__ch = _M_traits.translate_nocase(__ch);
else
__ch = _M_traits.translate(__ch);
bool __ret = false;
for (auto __c : _M_char_set)
if (__c == __ch)
{
__ret = true;
break;
}
if (__c == __ch)
{
__ret = true;
break;
}
if (!__ret && _M_traits.isctype(__oldch, _M_class_set))
__ret = true;
__ret = true;
else
{
_StringT __s = _M_get_str(__ch);
for (auto& __it : _M_range_set)
if (__it.first <= __s && __s <= __it.second)
{
__ret = true;
break;
}
}
{
_StringT __s = _M_get_str(__ch);
for (auto& __it : _M_range_set)
if (__it.first <= __s && __s <= __it.second)
{
__ret = true;
break;
}
}
if (_M_is_non_matching)
__ret = !__ret;
__ret = !__ret;
return __ret;
}
......
......@@ -164,21 +164,21 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
operator&(syntax_option_type __a, syntax_option_type __b)
{
return (syntax_option_type)(static_cast<unsigned int>(__a)
& static_cast<unsigned int>(__b));
& static_cast<unsigned int>(__b));
}
constexpr inline syntax_option_type
operator|(syntax_option_type __a, syntax_option_type __b)
{
return (syntax_option_type)(static_cast<unsigned int>(__a)
| static_cast<unsigned int>(__b));
| static_cast<unsigned int>(__b));
}
constexpr inline syntax_option_type
operator^(syntax_option_type __a, syntax_option_type __b)
{
return (syntax_option_type)(static_cast<unsigned int>(__a)
^ static_cast<unsigned int>(__b));
^ static_cast<unsigned int>(__b));
}
constexpr inline syntax_option_type
......
......@@ -76,17 +76,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
protected:
typedef typename _NFA<_CharT, _TraitsT>::_SizeT _SizeT;
_Executor(_BiIter __begin,
_BiIter __end,
_ResultsT& __results,
_FlagT __flags,
_SizeT __size)
_BiIter __end,
_ResultsT& __results,
_FlagT __flags,
_SizeT __size)
: _M_current(__begin), _M_end(__end), _M_results(__results),
_M_flags(__flags)
_M_flags(__flags)
{
__size += 2;
_M_results.resize(__size);
for (auto __i = 0; __i < __size; __i++)
_M_results[__i].matched = false;
__size += 2;
_M_results.resize(__size);
for (auto __i = 0; __i < __size; __i++)
_M_results[__i].matched = false;
}
_BiIter _M_current;
......@@ -121,12 +121,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
typedef regex_constants::match_flag_type _FlagT;
_DFSExecutor(_BiIter __begin,
_BiIter __end,
_ResultsT& __results,
const _RegexT& __nfa,
_FlagT __flags)
_BiIter __end,
_ResultsT& __results,
const _RegexT& __nfa,
_FlagT __flags)
: _BaseT(__begin, __end, __results, __flags, __nfa._M_sub_count()),
_M_traits(_TraitsT()), _M_nfa(__nfa), _M_results_ret(this->_M_results)
_M_traits(_TraitsT()), _M_nfa(__nfa), _M_results_ret(this->_M_results)
{ }
void
......@@ -139,8 +139,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
private:
template<bool __match_mode>
bool
_M_dfs(_StateIdT __i);
bool
_M_dfs(_StateIdT __i);
_ResultsVec _M_results_ret;
_TraitsT _M_traits;
......@@ -174,17 +174,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
typedef regex_constants::match_flag_type _FlagT;
_BFSExecutor(_BiIter __begin,
_BiIter __end,
_ResultsT& __results,
const _RegexT& __nfa,
_FlagT __flags)
_BiIter __end,
_ResultsT& __results,
const _RegexT& __nfa,
_FlagT __flags)
: _BaseT(__begin, __end, __results, __flags, __nfa._M_sub_count()),
_M_nfa(__nfa)
_M_nfa(__nfa)
{
if (_M_nfa._M_start() != _S_invalid_state_id)
_M_covered[_M_nfa._M_start()] =
_ResultsPtr(new _ResultsVec(this->_M_results));
_M_e_closure();
if (_M_nfa._M_start() != _S_invalid_state_id)
_M_covered[_M_nfa._M_start()] =
_ResultsPtr(new _ResultsVec(this->_M_results));
_M_e_closure();
}
void
......@@ -197,8 +197,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
private:
template<bool __match_mode>
void
_M_main_loop();
void
_M_main_loop();
void
_M_e_closure();
......
......@@ -41,97 +41,97 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_M_dfs(_StateIdT __i)
{
if (__i == _S_invalid_state_id)
// This is not that certain. Need deeper investigate.
return false;
// This is not that certain. Need deeper investigate.
return false;
auto& __current = this->_M_current;
auto& __end = this->_M_end;
auto& __results = _M_results_ret;
const auto& __state = _M_nfa[__i];
bool __ret = false;
switch (__state._M_opcode)
{
case _S_opcode_alternative:
// Greedy mode by default. For non-greedy mode,
// swap _M_alt and _M_next.
// TODO: Add greedy mode option.
__ret = _M_dfs<__match_mode>(__state._M_alt)
|| _M_dfs<__match_mode>(__state._M_next);
break;
case _S_opcode_subexpr_begin:
// Here's the critical part: if there's nothing changed since last
// visit, do NOT continue. This prevents the executor from get into
// infinite loop when use "()*" to match "".
//
// Every change on __results will be roll back after the recursion
// step finished.
if (!__results[__state._M_subexpr].matched
|| __results[__state._M_subexpr].first != __current)
{
auto __back = __current;
__results[__state._M_subexpr].first = __current;
__ret = _M_dfs<__match_mode>(__state._M_next);
__results[__state._M_subexpr].first = __back;
}
break;
case _S_opcode_subexpr_end:
if (__results[__state._M_subexpr].second != __current
|| __results[__state._M_subexpr].matched != true)
{
auto __back = __results[__state._M_subexpr];
__results[__state._M_subexpr].second = __current;
__results[__state._M_subexpr].matched = true;
__ret = _M_dfs<__match_mode>(__state._M_next);
__results[__state._M_subexpr] = __back;
}
else
__ret = _M_dfs<__match_mode>(__state._M_next);
break;
case _S_opcode_match:
if (__current != __end && __state._M_matches(*__current))
{
++__current;
__ret = _M_dfs<__match_mode>(__state._M_next);
--__current;
}
break;
// First fetch the matched result from __results as __submatch;
// then compare it with
// (__current, __current + (__submatch.second - __submatch.first))
// If matched, keep going; else just return to try another state.
case _S_opcode_backref:
{
auto& __submatch = __results[__state._M_backref_index];
if (!__submatch.matched)
break;
auto __last = __current;
for (auto __tmp = __submatch.first;
__last != __end && __tmp != __submatch.second;
++__tmp)
++__last;
if (_M_traits.transform(__submatch.first, __submatch.second)
== _M_traits.transform(__current, __last))
if (__last != __current)
{
auto __backup = __current;
__current = __last;
__ret = _M_dfs<__match_mode>(__state._M_next);
__current = __backup;
}
else
__ret = _M_dfs<__match_mode>(__state._M_next);
}
break;
case _S_opcode_accept:
if (__match_mode)
__ret = __current == __end;
else
__ret = true;
if (__ret)
this->_M_results = __results;
break;
default:
_GLIBCXX_DEBUG_ASSERT(false);
}
{
case _S_opcode_alternative:
// Greedy mode by default. For non-greedy mode,
// swap _M_alt and _M_next.
// TODO: Add greedy mode option.
__ret = _M_dfs<__match_mode>(__state._M_alt)
|| _M_dfs<__match_mode>(__state._M_next);
break;
case _S_opcode_subexpr_begin:
// Here's the critical part: if there's nothing changed since last
// visit, do NOT continue. This prevents the executor from get into
// infinite loop when use "()*" to match "".
//
// Every change on __results will be roll back after the recursion
// step finished.
if (!__results[__state._M_subexpr].matched
|| __results[__state._M_subexpr].first != __current)
{
auto __back = __current;
__results[__state._M_subexpr].first = __current;
__ret = _M_dfs<__match_mode>(__state._M_next);
__results[__state._M_subexpr].first = __back;
}
break;
case _S_opcode_subexpr_end:
if (__results[__state._M_subexpr].second != __current
|| __results[__state._M_subexpr].matched != true)
{
auto __back = __results[__state._M_subexpr];
__results[__state._M_subexpr].second = __current;
__results[__state._M_subexpr].matched = true;
__ret = _M_dfs<__match_mode>(__state._M_next);
__results[__state._M_subexpr] = __back;
}
else
__ret = _M_dfs<__match_mode>(__state._M_next);
break;
case _S_opcode_match:
if (__current != __end && __state._M_matches(*__current))
{
++__current;
__ret = _M_dfs<__match_mode>(__state._M_next);
--__current;
}
break;
// First fetch the matched result from __results as __submatch;
// then compare it with
// (__current, __current + (__submatch.second - __submatch.first))
// If matched, keep going; else just return to try another state.
case _S_opcode_backref:
{
auto& __submatch = __results[__state._M_backref_index];
if (!__submatch.matched)
break;
auto __last = __current;
for (auto __tmp = __submatch.first;
__last != __end && __tmp != __submatch.second;
++__tmp)
++__last;
if (_M_traits.transform(__submatch.first, __submatch.second)
== _M_traits.transform(__current, __last))
if (__last != __current)
{
auto __backup = __current;
__current = __last;
__ret = _M_dfs<__match_mode>(__state._M_next);
__current = __backup;
}
else
__ret = _M_dfs<__match_mode>(__state._M_next);
}
break;
case _S_opcode_accept:
if (__match_mode)
__ret = __current == __end;
else
__ret = true;
if (__ret)
this->_M_results = __results;
break;
default:
_GLIBCXX_DEBUG_ASSERT(false);
}
return __ret;
}
......@@ -142,14 +142,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_M_main_loop()
{
while (this->_M_current != this->_M_end)
{
if (!__match_mode)
if (_M_includes_some())
return;
_M_move();
++this->_M_current;
_M_e_closure();
}
{
if (!__match_mode)
if (_M_includes_some())
return;
_M_move();
++this->_M_current;
_M_e_closure();
}
_M_includes_some();
}
......@@ -162,73 +162,73 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
std::queue<_StateIdT> __q;
std::vector<bool> __in_q(_M_nfa.size(), false);
for (auto& __it : _M_covered)
{
__in_q[__it.first] = true;
__q.push(__it.first);
}
{
__in_q[__it.first] = true;
__q.push(__it.first);
}
while (!__q.empty())
{
auto __u = __q.front();
__q.pop();
__in_q[__u] = false;
const auto& __state = _M_nfa[__u];
{
auto __u = __q.front();
__q.pop();
__in_q[__u] = false;
const auto& __state = _M_nfa[__u];
// Can be implemented using method, but there're too much arguments.
// I would use macro function before C++11, but lambda is a better
// choice, since hopefully compiler can inline it.
auto __add_visited_state = [&](_StateIdT __v)
{
if (__v == _S_invalid_state_id)
return;
if (_M_covered.count(__u) != 0
&& (_M_covered.count(__v) == 0
|| _M_match_less_than(*_M_covered[__u], *_M_covered[__v])))
{
_M_covered[__v] = _ResultsPtr(new _ResultsVec(*_M_covered[__u]));
// if a state is updated, it's outgoing neighbors should be
// reconsidered too. Push them to the queue.
if (!__in_q[__v])
{
__in_q[__v] = true;
__q.push(__v);
}
}
};
// Can be implemented using method, but there're too much arguments.
// I would use macro function before C++11, but lambda is a better
// choice, since hopefully compiler can inline it.
auto __add_visited_state = [&](_StateIdT __v)
{
if (__v == _S_invalid_state_id)
return;
if (_M_covered.count(__u) != 0
&& (_M_covered.count(__v) == 0
|| _M_match_less_than(*_M_covered[__u], *_M_covered[__v])))
{
_M_covered[__v] = _ResultsPtr(new _ResultsVec(*_M_covered[__u]));
// if a state is updated, it's outgoing neighbors should be
// reconsidered too. Push them to the queue.
if (!__in_q[__v])
{
__in_q[__v] = true;
__q.push(__v);
}
}
};
switch (__state._M_opcode)
{
case _S_opcode_alternative:
__add_visited_state(__state._M_next);
__add_visited_state(__state._M_alt);
break;
case _S_opcode_subexpr_begin:
{
auto& __cu = *_M_covered[__u];
auto __back = __cu[__state._M_subexpr].first;
__cu[__state._M_subexpr].first = __current;
__add_visited_state(__state._M_next);
__cu[__state._M_subexpr].first = __back;
}
break;
case _S_opcode_subexpr_end:
{
auto& __cu = *_M_covered[__u];
auto __back = __cu[__state._M_subexpr];
__cu[__state._M_subexpr].second = __current;
__cu[__state._M_subexpr].matched = true;
__add_visited_state(__state._M_next);
__cu[__state._M_subexpr] = __back;
}
break;
case _S_opcode_match:
break;
case _S_opcode_accept:
__add_visited_state(__state._M_next);
break;
default:
_GLIBCXX_DEBUG_ASSERT(false);
}
}
switch (__state._M_opcode)
{
case _S_opcode_alternative:
__add_visited_state(__state._M_next);
__add_visited_state(__state._M_alt);
break;
case _S_opcode_subexpr_begin:
{
auto& __cu = *_M_covered[__u];
auto __back = __cu[__state._M_subexpr].first;
__cu[__state._M_subexpr].first = __current;
__add_visited_state(__state._M_next);
__cu[__state._M_subexpr].first = __back;
}
break;
case _S_opcode_subexpr_end:
{
auto& __cu = *_M_covered[__u];
auto __back = __cu[__state._M_subexpr];
__cu[__state._M_subexpr].second = __current;
__cu[__state._M_subexpr].matched = true;
__add_visited_state(__state._M_next);
__cu[__state._M_subexpr] = __back;
}
break;
case _S_opcode_match:
break;
case _S_opcode_accept:
__add_visited_state(__state._M_next);
break;
default:
_GLIBCXX_DEBUG_ASSERT(false);
}
}
}
template<typename _BiIter, typename _Alloc,
......@@ -238,15 +238,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
{
decltype(_M_covered) __next;
for (auto& __it : _M_covered)
{
const auto& __state = _M_nfa[__it.first];
if (__state._M_opcode == _S_opcode_match
&& __state._M_matches(*this->_M_current))
if (__state._M_next != _S_invalid_state_id)
if (__next.count(__state._M_next) == 0
|| _M_match_less_than(*__it.second, *__next[__state._M_next]))
__next[__state._M_next] = move(__it.second);
}
{
const auto& __state = _M_nfa[__it.first];
if (__state._M_opcode == _S_opcode_match
&& __state._M_matches(*this->_M_current))
if (__state._M_next != _S_invalid_state_id)
if (__next.count(__state._M_next) == 0
|| _M_match_less_than(*__it.second, *__next[__state._M_next]))
__next[__state._M_next] = move(__it.second);
}
_M_covered = move(__next);
}
......@@ -259,21 +259,21 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_GLIBCXX_DEBUG_ASSERT(__u.size() == __v.size());
auto __size = __u.size();
for (auto __i = 0; __i < __size; __i++)
{
auto& __uit = __u[__i], __vit = __v[__i];
if (__uit.matched && !__vit.matched)
return true;
if (!__uit.matched && __vit.matched)
return false;
if (__uit.matched && __vit.matched)
{
// GREEDY
if (__uit.first != __vit.first)
return __uit.first < __vit.first;
if (__uit.second != __vit.second)
return __uit.second > __vit.second;
}
}
{
auto& __uit = __u[__i], __vit = __v[__i];
if (__uit.matched && !__vit.matched)
return true;
if (!__uit.matched && __vit.matched)
return false;
if (__uit.matched && __vit.matched)
{
// GREEDY
if (__uit.first != __vit.first)
return __uit.first < __vit.first;
if (__uit.second != __vit.second)
return __uit.second > __vit.second;
}
}
return false;
}
......@@ -285,22 +285,22 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
auto& __s = _M_nfa._M_final_states();
auto& __t = _M_covered;
if (__s.size() > 0 && __t.size() > 0)
{
auto __first = __s.begin();
auto __second = __t.begin();
while (__first != __s.end() && __second != __t.end())
{
if (*__first < __second->first)
++__first;
else if (__second->first < *__first)
++__second;
else
{
this->_M_results = *__second->second;
return true;
}
}
}
{
auto __first = __s.begin();
auto __second = __t.begin();
while (__first != __s.end() && __second != __t.end())
{
if (*__first < __second->first)
++__first;
else if (__second->first < *__first)
++__second;
else
{
this->_M_results = *__second->second;
return true;
}
}
}
return false;
}
......@@ -308,19 +308,19 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
typename _CharT, typename _TraitsT>
std::unique_ptr<_Executor<_BiIter, _Alloc, _CharT, _TraitsT>>
__get_executor(_BiIter __b,
_BiIter __e,
match_results<_BiIter, _Alloc>& __m,
const basic_regex<_CharT, _TraitsT>& __re,
regex_constants::match_flag_type __flags)
_BiIter __e,
match_results<_BiIter, _Alloc>& __m,
const basic_regex<_CharT, _TraitsT>& __re,
regex_constants::match_flag_type __flags)
{
typedef std::unique_ptr<_Executor<_BiIter, _Alloc, _CharT, _TraitsT>>
_ExecutorPtr;
_ExecutorPtr;
typedef _DFSExecutor<_BiIter, _Alloc, _CharT, _TraitsT> _DFSExecutorT;
typedef _BFSExecutor<_BiIter, _Alloc, _CharT, _TraitsT> _BFSExecutorT;
auto __p = std::static_pointer_cast<_NFA<_CharT, _TraitsT>>
(__re._M_automaton);
(__re._M_automaton);
if (__p->_M_has_backref)
return _ExecutorPtr(new _DFSExecutorT(__b, __e, __m, *__p, __flags));
return _ExecutorPtr(new _DFSExecutorT(__b, __e, __m, *__p, __flags));
return _ExecutorPtr(new _BFSExecutorT(__b, __e, __m, *__p, __flags));
}
......
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