31 namespace std _GLIBCXX_VISIBILITY(default)
35 _GLIBCXX_BEGIN_NAMESPACE_VERSION
42 template<
typename,
bool,
bool>
50 template<
typename _TraitsT>
54 typedef typename _TraitsT::char_type _CharT;
55 typedef const _CharT* _IterT;
56 typedef _NFA<_TraitsT> _RegexT;
60 const typename _TraitsT::locale_type& __traits, _FlagT __flags);
64 {
return std::move(_M_nfa); }
68 typedef typename _TraitsT::string_type _StringT;
69 typedef typename _ScannerT::_TokenT _TokenT;
76 _M_match_token(_TokenT __token);
97 _M_bracket_expression();
99 template<
bool __icase,
bool __collate>
101 _M_insert_any_matcher_ecma();
103 template<
bool __icase,
bool __collate>
105 _M_insert_any_matcher_posix();
107 template<
bool __icase,
bool __collate>
109 _M_insert_char_matcher();
111 template<
bool __icase,
bool __collate>
113 _M_insert_character_class_matcher();
115 template<
bool __icase,
bool __collate>
117 _M_insert_bracket_matcher(
bool __neg);
121 template<
bool __icase,
bool __collate>
128 _M_cur_int_value(
int __radix);
136 auto ret = _M_stack.
top();
142 _ScannerT _M_scanner;
146 const _TraitsT& _M_traits;
147 const _CtypeT& _M_ctype;
150 template<
typename _Tp>
153 template<
typename _Ch,
typename _Tr,
typename _Alloc>
154 struct __has_contiguous_iter<std::
basic_string<_Ch, _Tr, _Alloc>>
158 template<
typename _Tp,
typename _Alloc>
159 struct __has_contiguous_iter<std::
vector<_Tp, _Alloc>>
163 template<
typename _Tp>
166 template<
typename _CharT>
169 template<
typename _Tp,
typename _Cont>
171 __is_contiguous_normal_iter<__gnu_cxx::__normal_iterator<_Tp, _Cont>>
175 template<
typename _Iter,
typename _TraitsT>
176 using __enable_if_contiguous_normal_iter
177 =
typename enable_if< __is_contiguous_normal_iter<_Iter>::value,
180 template<
typename _Iter,
typename _TraitsT>
181 using __disable_if_contiguous_normal_iter
182 =
typename enable_if< !__is_contiguous_normal_iter<_Iter>::value,
185 template<
typename _FwdIter,
typename _TraitsT>
186 inline __enable_if_contiguous_normal_iter<_FwdIter, _TraitsT>
187 __compile_nfa(_FwdIter __first, _FwdIter __last,
188 const typename _TraitsT::locale_type& __loc,
191 size_t __len = __last - __first;
194 return _Cmplr(__cfirst, __cfirst + __len, __loc, __flags)._M_get_nfa();
197 template<
typename _FwdIter,
typename _TraitsT>
198 inline __disable_if_contiguous_normal_iter<_FwdIter, _TraitsT>
199 __compile_nfa(_FwdIter __first, _FwdIter __last,
200 const typename _TraitsT::locale_type& __loc,
204 return __compile_nfa(__str.
data(), __str.
data() + __str.
size(), __loc,
209 template<
typename _TraitsT,
bool __icase,
bool __collate>
210 class _RegexTranslator
213 typedef typename _TraitsT::char_type _CharT;
214 typedef typename _TraitsT::string_type _StringT;
215 typedef typename std::conditional<__collate,
217 _CharT>::type _StrTransT;
220 _RegexTranslator(
const _TraitsT& __traits)
221 : _M_traits(__traits)
225 _M_translate(_CharT __ch)
const 228 return _M_traits.translate_nocase(__ch);
230 return _M_traits.translate(__ch);
236 _M_transform(_CharT __ch)
const 244 _M_transform_impl(_CharT __ch,
false_type)
const 248 _M_transform_impl(_CharT __ch,
true_type)
const 250 _StrTransT __str = _StrTransT(1, _M_translate(__ch));
251 return _M_traits.transform(__str.begin(), __str.end());
254 const _TraitsT& _M_traits;
257 template<
typename _TraitsT>
258 class _RegexTranslator<_TraitsT, false, false>
261 typedef typename _TraitsT::char_type _CharT;
262 typedef _CharT _StrTransT;
265 _RegexTranslator(
const _TraitsT&)
269 _M_translate(_CharT __ch)
const 273 _M_transform(_CharT __ch)
const 277 template<
typename _TraitsT,
bool __is_ecma,
bool __icase,
bool __collate>
280 template<
typename _TraitsT,
bool __icase,
bool __collate>
281 struct _AnyMatcher<_TraitsT, false, __icase, __collate>
283 typedef _RegexTranslator<_TraitsT, __icase, __collate> _TransT;
284 typedef typename _TransT::_CharT _CharT;
287 _AnyMatcher(
const _TraitsT& __traits)
288 : _M_translator(__traits)
292 operator()(_CharT __ch)
const 294 static auto __nul = _M_translator._M_translate(
'\0');
295 return _M_translator._M_translate(__ch) != __nul;
298 _TransT _M_translator;
301 template<
typename _TraitsT,
bool __icase,
bool __collate>
302 struct _AnyMatcher<_TraitsT, true, __icase, __collate>
304 typedef _RegexTranslator<_TraitsT, __icase, __collate> _TransT;
305 typedef typename _TransT::_CharT _CharT;
308 _AnyMatcher(
const _TraitsT& __traits)
309 : _M_translator(__traits)
313 operator()(_CharT __ch)
const 314 {
return _M_apply(__ch,
typename is_same<_CharT, char>::type()); }
319 auto __c = _M_translator._M_translate(__ch);
320 auto __n = _M_translator._M_translate(
'\n');
321 auto __r = _M_translator._M_translate(
'\r');
322 return __c != __n && __c != __r;
328 auto __c = _M_translator._M_translate(__ch);
329 auto __n = _M_translator._M_translate(
'\n');
330 auto __r = _M_translator._M_translate(
'\r');
331 auto __u2028 = _M_translator._M_translate(u
'\u2028');
332 auto __u2029 = _M_translator._M_translate(u
'\u2029');
333 return __c != __n && __c != __r && __c != __u2028 && __c != __u2029;
336 _TransT _M_translator;
339 template<
typename _TraitsT,
bool __icase,
bool __collate>
342 typedef _RegexTranslator<_TraitsT, __icase, __collate> _TransT;
343 typedef typename _TransT::_CharT _CharT;
345 _CharMatcher(_CharT __ch,
const _TraitsT& __traits)
346 : _M_translator(__traits), _M_ch(_M_translator._M_translate(__ch))
350 operator()(_CharT __ch)
const 351 {
return _M_ch == _M_translator._M_translate(__ch); }
353 _TransT _M_translator;
358 template<
typename _TraitsT,
bool __icase,
bool __collate>
362 typedef _RegexTranslator<_TraitsT, __icase, __collate> _TransT;
363 typedef typename _TransT::_CharT _CharT;
364 typedef typename _TransT::_StrTransT _StrTransT;
365 typedef typename _TraitsT::string_type _StringT;
366 typedef typename _TraitsT::char_class_type _CharClassT;
370 const _TraitsT& __traits)
371 : _M_class_set(0), _M_translator(__traits), _M_traits(__traits),
372 _M_is_non_matching(__is_non_matching)
376 operator()(_CharT __ch)
const 378 _GLIBCXX_DEBUG_ASSERT(_M_is_ready);
379 return _M_apply(__ch, _UseCache());
383 _M_add_char(_CharT __c)
385 _M_char_set.push_back(_M_translator._M_translate(__c));
386 _GLIBCXX_DEBUG_ONLY(_M_is_ready =
false);
390 _M_add_collate_element(
const _StringT& __s)
392 auto __st = _M_traits.lookup_collatename(__s.data(),
393 __s.data() + __s.size());
396 "Invalid collate element.");
397 _M_char_set.push_back(_M_translator._M_translate(__st[0]));
398 _GLIBCXX_DEBUG_ONLY(_M_is_ready =
false);
403 _M_add_equivalence_class(
const _StringT& __s)
405 auto __st = _M_traits.lookup_collatename(__s.data(),
406 __s.data() + __s.size());
409 "Invalid equivalence class.");
410 __st = _M_traits.transform_primary(__st.data(),
411 __st.data() + __st.size());
412 _M_equiv_set.push_back(__st);
413 _GLIBCXX_DEBUG_ONLY(_M_is_ready =
false);
418 _M_add_character_class(
const _StringT& __s,
bool __neg)
420 auto __mask = _M_traits.lookup_classname(__s.data(),
421 __s.data() + __s.size(),
425 "Invalid character class.");
427 _M_class_set |= __mask;
429 _M_neg_class_set.push_back(__mask);
430 _GLIBCXX_DEBUG_ONLY(_M_is_ready =
false);
434 _M_make_range(_CharT __l, _CharT __r)
438 "Invalid range in bracket expression.");
439 _M_range_set.push_back(
make_pair(_M_translator._M_transform(__l),
440 _M_translator._M_transform(__r)));
441 _GLIBCXX_DEBUG_ONLY(_M_is_ready =
false);
447 std::sort(_M_char_set.begin(), _M_char_set.end());
448 auto __end =
std::unique(_M_char_set.begin(), _M_char_set.end());
449 _M_char_set.erase(__end, _M_char_set.end());
450 _M_make_cache(_UseCache());
451 _GLIBCXX_DEBUG_ONLY(_M_is_ready =
true);
456 typedef typename std::is_same<_CharT, char>::type _UseCache;
458 static constexpr
size_t 461 return 1ul << (
sizeof(_CharT) * __CHAR_BIT__ *
int(_UseCache::value));
465 typedef typename std::conditional<_UseCache::value,
467 _Dummy>::type _CacheT;
468 typedef typename std::make_unsigned<_CharT>::type _UnsignedCharT;
475 {
return _M_cache[
static_cast<_UnsignedCharT
>(__ch)]; }
480 for (
unsigned __i = 0; __i < _M_cache.size(); __i++)
481 _M_cache[__i] = _M_apply(static_cast<_CharT>(__i),
false_type());
493 _CharClassT _M_class_set;
494 _TransT _M_translator;
495 const _TraitsT& _M_traits;
496 bool _M_is_non_matching;
498 #ifdef _GLIBCXX_DEBUG 499 bool _M_is_ready =
false;
504 _GLIBCXX_END_NAMESPACE_VERSION
Scans an input range for regex tokens.
Builds an NFA from an input iterator range.
integral_constant< bool, false > false_type
The type used as a compile-time boolean with false value.
constexpr error_type error_range(_S_error_range)
const _CharT * data() const noexcept
Return const pointer to contents.
void sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
Sort the elements of a sequence using a predicate for comparison.
Managing sequences of characters and character-like objects.
syntax_option_type
This is a bitmask type indicating how to interpret the regex.
size_type size() const noexcept
Returns the number of characters in the string, not including any null-termination.
A smart pointer with reference-counted copy semantics.
Primary class template ctype facet.This template class defines classification and conversion function...
_Tp * __addressof(_Tp &__r) noexcept
Same as C++11 std::addressof.
Matches a character range (bracket expression)
Struct holding two objects of arbitrary type.
A standard container which offers fixed time access to individual elements in any order...
void pop()
Removes first element.
Describes a sequence of one or more _State, its current start and end(s). This structure contains fra...
constexpr pair< typename __decay_and_strip< _T1 >::__type, typename __decay_and_strip< _T2 >::__type > make_pair(_T1 &&__x, _T2 &&__y)
A convenience wrapper for creating a pair from two objects.
constexpr error_type error_collate(_S_error_collate)
The bitset class represents a fixed-size sequence of bits.(Note that bitset does not meet the formal ...
ISO C++ entities toplevel namespace is std.
_ForwardIterator unique(_ForwardIterator __first, _ForwardIterator __last, _BinaryPredicate __binary_pred)
Remove consecutive values from a sequence using a predicate.