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 _TraitsT& __traits, _FlagT __flags);
64 {
return make_shared<_RegexT>(
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);
119 template<
bool __icase,
bool __collate>
125 _M_cur_int_value(
int __radix);
133 auto ret = _M_stack.
top();
139 const _TraitsT& _M_traits;
140 const _CtypeT& _M_ctype;
141 _ScannerT _M_scanner;
147 template<
typename _TraitsT>
149 __compile_nfa(
const typename _TraitsT::char_type* __first,
150 const typename _TraitsT::char_type* __last,
151 const _TraitsT& __traits,
155 return _Cmplr(__first, __last, __traits, __flags)._M_get_nfa();
159 template<
typename _TraitsT,
bool __icase,
bool __collate>
160 class _RegexTranslator
163 typedef typename _TraitsT::char_type _CharT;
164 typedef typename _TraitsT::string_type _StringT;
165 typedef typename std::conditional<__collate,
167 _CharT>::type _StrTransT;
170 _RegexTranslator(
const _TraitsT& __traits)
171 : _M_traits(__traits)
175 _M_translate(_CharT __ch)
const
178 return _M_traits.translate_nocase(__ch);
180 return _M_traits.translate(__ch);
186 _M_transform(_CharT __ch)
const
188 return _M_transform_impl(__ch,
typename integral_constant<
bool,
194 _M_transform_impl(_CharT __ch, false_type)
const
198 _M_transform_impl(_CharT __ch, true_type)
const
200 _StrTransT __str = _StrTransT(1, _M_translate(__ch));
201 return _M_traits.transform(__str.begin(), __str.end());
204 const _TraitsT& _M_traits;
207 template<
typename _TraitsT>
208 class _RegexTranslator<_TraitsT, false, false>
211 typedef typename _TraitsT::char_type _CharT;
212 typedef _CharT _StrTransT;
215 _RegexTranslator(
const _TraitsT& __traits)
219 _M_translate(_CharT __ch)
const
223 _M_transform(_CharT __ch)
const
227 template<
typename _TraitsT,
bool __is_ecma,
bool __icase,
bool __collate>
230 template<
typename _TraitsT,
bool __icase,
bool __collate>
231 struct _AnyMatcher<_TraitsT, false, __icase, __collate>
233 typedef _RegexTranslator<_TraitsT, __icase, __collate> _TransT;
234 typedef typename _TransT::_CharT _CharT;
237 _AnyMatcher(
const _TraitsT& __traits)
238 : _M_translator(__traits)
242 operator()(_CharT __ch)
const
244 static auto __nul = _M_translator._M_translate(
'\0');
245 return _M_translator._M_translate(__ch) != __nul;
248 _TransT _M_translator;
251 template<
typename _TraitsT,
bool __icase,
bool __collate>
252 struct _AnyMatcher<_TraitsT, true, __icase, __collate>
254 typedef _RegexTranslator<_TraitsT, __icase, __collate> _TransT;
255 typedef typename _TransT::_CharT _CharT;
258 _AnyMatcher(
const _TraitsT& __traits)
259 : _M_translator(__traits)
263 operator()(_CharT __ch)
const
264 {
return _M_apply(__ch,
typename is_same<_CharT, char>::type()); }
267 _M_apply(_CharT __ch, true_type)
const
269 auto __c = _M_translator._M_translate(__ch);
270 auto __n = _M_translator._M_translate(
'\n');
271 auto __r = _M_translator._M_translate(
'\r');
272 return __c != __n && __c != __r;
276 _M_apply(_CharT __ch, false_type)
const
278 auto __c = _M_translator._M_translate(__ch);
279 auto __n = _M_translator._M_translate(
'\n');
280 auto __r = _M_translator._M_translate(
'\r');
281 auto __u2028 = _M_translator._M_translate(u
'\u2028');
282 auto __u2029 = _M_translator._M_translate(u
'\u2029');
283 return __c != __n && __c != __r && __c != __u2028 && __c != __u2029;
286 _TransT _M_translator;
289 template<
typename _TraitsT,
bool __icase,
bool __collate>
292 typedef _RegexTranslator<_TraitsT, __icase, __collate> _TransT;
293 typedef typename _TransT::_CharT _CharT;
295 _CharMatcher(_CharT __ch,
const _TraitsT& __traits)
296 : _M_translator(__traits), _M_ch(_M_translator._M_translate(__ch))
300 operator()(_CharT __ch)
const
301 {
return _M_ch == _M_translator._M_translate(__ch); }
303 _TransT _M_translator;
308 template<
typename _TraitsT,
bool __icase,
bool __collate>
309 struct _BracketMatcher
312 typedef _RegexTranslator<_TraitsT, __icase, __collate> _TransT;
313 typedef typename _TransT::_CharT _CharT;
314 typedef typename _TransT::_StrTransT _StrTransT;
315 typedef typename _TraitsT::string_type _StringT;
316 typedef typename _TraitsT::char_class_type _CharClassT;
319 _BracketMatcher(
bool __is_non_matching,
320 const _TraitsT& __traits)
321 : _M_class_set(0), _M_translator(__traits), _M_traits(__traits),
322 _M_is_non_matching(__is_non_matching)
323 #ifdef _GLIBCXX_DEBUG
329 operator()(_CharT __ch)
const
331 _GLIBCXX_DEBUG_ASSERT(_M_is_ready);
332 return _M_apply(__ch, _IsChar());
336 _M_add_char(_CharT __c)
338 _M_char_set.
push_back(_M_translator._M_translate(__c));
339 #ifdef _GLIBCXX_DEBUG
345 _M_add_collating_element(
const _StringT& __s)
347 auto __st = _M_traits.lookup_collatename(__s.data(),
348 __s.data() + __s.size());
351 _M_char_set.
push_back(_M_translator._M_translate(__st[0]));
352 #ifdef _GLIBCXX_DEBUG
358 _M_add_equivalence_class(
const _StringT& __s)
360 auto __st = _M_traits.lookup_collatename(__s.data(),
361 __s.data() + __s.size());
364 __st = _M_traits.transform_primary(__st.data(),
365 __st.data() + __st.size());
367 #ifdef _GLIBCXX_DEBUG
374 _M_add_character_class(
const _StringT& __s,
bool __neg)
376 auto __mask = _M_traits.lookup_classname(__s.data(),
377 __s.data() + __s.size(),
382 _M_class_set |= __mask;
385 #ifdef _GLIBCXX_DEBUG
391 _M_make_range(_CharT __l, _CharT __r)
393 _M_range_set.push_back(
make_pair(_M_translator._M_transform(__l),
394 _M_translator._M_transform(__r)));
395 #ifdef _GLIBCXX_DEBUG
403 _M_make_cache(_IsChar());
404 #ifdef _GLIBCXX_DEBUG
410 typedef typename is_same<_CharT, char>::type _IsChar;
412 typedef typename conditional<_IsChar::value,
413 std::bitset<1 << (8 * sizeof(_CharT))>,
414 _Dummy>::type _CacheT;
415 typedef typename make_unsigned<_CharT>::type _UnsignedCharT;
419 _M_apply(_CharT __ch, false_type)
const;
422 _M_apply(_CharT __ch, true_type)
const
423 {
return _M_cache[
static_cast<_UnsignedCharT
>(__ch)]; }
426 _M_make_cache(true_type)
428 for (
int __i = 0; __i < _M_cache.size(); __i++)
429 _M_cache[static_cast<_UnsignedCharT>(__i)] =
430 _M_apply(__i, false_type());
434 _M_make_cache(false_type)
443 _CharClassT _M_class_set;
444 _TransT _M_translator;
445 const _TraitsT& _M_traits;
446 bool _M_is_non_matching;
447 #ifdef _GLIBCXX_DEBUG
453 _GLIBCXX_END_NAMESPACE_VERSION
457 #include <bits/regex_compiler.tcc>
Primary class template ctype facet.This template class defines classification and conversion function...
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
Matches a character range (bracket expression)
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.
void pop()
Removes first element.
A smart pointer with reference-counted copy semantics.
syntax_option_type
This is a bitmask type indicating how to interpret the regex.
ISO C++ entities toplevel namespace is std.
void push_back(const value_type &__x)
Add data to the end of the vector.
Describes a sequence of one or more _State, its current start and end(s). This structure contains fra...
constexpr error_type error_ctype(_S_error_ctype)
Builds an NFA from an input iterator interval.
Scans an input range for regex tokens.
constexpr error_type error_collate(_S_error_collate)