49 namespace std _GLIBCXX_VISIBILITY(default)
53 _GLIBCXX_BEGIN_NAMESPACE_VERSION
55 template<
typename _CharT>
57 _Scanner(
typename _Scanner::_IterT __begin,
58 typename _Scanner::_IterT __end,
60 : _ScannerBase(__flags),
61 _M_current(__begin), _M_end(__end),
63 _M_eat_escape(_M_is_ecma()
64 ? &_Scanner::_M_eat_escape_ecma
65 : &_Scanner::_M_eat_escape_posix)
68 template<
typename _CharT>
73 if (_M_current == _M_end)
75 _M_token = _S_token_eof;
79 if (_M_state == _S_state_normal)
81 else if (_M_state == _S_state_in_bracket)
83 else if (_M_state == _S_state_in_brace)
87 _GLIBCXX_DEBUG_ASSERT(
false);
94 template<
typename _CharT>
99 auto __c = *_M_current++;
101 if (std::strchr(_M_spec_char, _M_ctype.narrow(__c,
' ')) ==
nullptr)
103 _M_token = _S_token_ord_char;
104 _M_value.assign(1, __c);
109 if (_M_current == _M_end)
113 || (*_M_current !=
'('
114 && *_M_current !=
')'
115 && *_M_current !=
'{'))
117 (this->*_M_eat_escape)();
124 if (_M_is_ecma() && *_M_current ==
'?')
126 if (++_M_current == _M_end)
129 if (*_M_current ==
':')
132 _M_token = _S_token_subexpr_no_group_begin;
134 else if (*_M_current ==
'=')
137 _M_token = _S_token_subexpr_lookahead_begin;
138 _M_value.assign(1,
'p');
140 else if (*_M_current ==
'!')
143 _M_token = _S_token_subexpr_lookahead_begin;
144 _M_value.assign(1,
'n');
150 _M_token = _S_token_subexpr_no_group_begin;
152 _M_token = _S_token_subexpr_begin;
155 _M_token = _S_token_subexpr_end;
158 _M_state = _S_state_in_bracket;
159 _M_at_bracket_start =
true;
160 if (_M_current != _M_end && *_M_current ==
'^')
162 _M_token = _S_token_bracket_neg_begin;
166 _M_token = _S_token_bracket_begin;
170 _M_state = _S_state_in_brace;
171 _M_token = _S_token_interval_begin;
173 else if (__c !=
']' && __c !=
'}')
175 auto __it = _M_token_tbl;
176 auto __narrowc = _M_ctype.narrow(__c,
'\0');
177 for (; __it->first !=
'\0'; ++__it)
178 if (__it->first == __narrowc)
180 _M_token = __it->second;
183 _GLIBCXX_DEBUG_ASSERT(
false);
187 _M_token = _S_token_ord_char;
188 _M_value.assign(1, __c);
195 template<
typename _CharT>
200 if (_M_current == _M_end)
203 auto __c = *_M_current++;
207 if (_M_current == _M_end)
210 if (*_M_current ==
'.')
212 _M_token = _S_token_collsymbol;
213 _M_eat_class(*_M_current++);
215 else if (*_M_current ==
':')
217 _M_token = _S_token_char_class_name;
218 _M_eat_class(*_M_current++);
220 else if (*_M_current ==
'=')
222 _M_token = _S_token_equiv_class_name;
223 _M_eat_class(*_M_current++);
227 _M_token = _S_token_ord_char;
228 _M_value.assign(1, __c);
234 else if (__c ==
']' && (_M_is_ecma() || !_M_at_bracket_start))
236 _M_token = _S_token_bracket_end;
237 _M_state = _S_state_normal;
240 else if (__c ==
'\\' && (_M_is_ecma() || _M_is_awk()))
241 (this->*_M_eat_escape)();
244 _M_token = _S_token_ord_char;
245 _M_value.assign(1, __c);
247 _M_at_bracket_start =
false;
252 template<
typename _CharT>
257 if (_M_current == _M_end)
260 auto __c = *_M_current++;
262 if (_M_ctype.is(_CtypeT::digit, __c))
264 _M_token = _S_token_dup_count;
265 _M_value.assign(1, __c);
266 while (_M_current != _M_end
267 && _M_ctype.is(_CtypeT::digit, *_M_current))
268 _M_value += *_M_current++;
271 _M_token = _S_token_comma;
273 else if (_M_is_basic())
275 if (__c ==
'\\' && _M_current != _M_end && *_M_current ==
'}')
277 _M_state = _S_state_normal;
278 _M_token = _S_token_interval_end;
286 _M_state = _S_state_normal;
287 _M_token = _S_token_interval_end;
293 template<
typename _CharT>
298 if (_M_current == _M_end)
301 auto __c = *_M_current++;
302 auto __pos = _M_find_escape(_M_ctype.narrow(__c,
'\0'));
304 if (__pos !=
nullptr && (__c !=
'b' || _M_state == _S_state_in_bracket))
306 _M_token = _S_token_ord_char;
307 _M_value.assign(1, *__pos);
311 _M_token = _S_token_word_bound;
312 _M_value.assign(1,
'p');
316 _M_token = _S_token_word_bound;
317 _M_value.assign(1,
'n');
327 _M_token = _S_token_quoted_class;
328 _M_value.assign(1, __c);
332 if (_M_current == _M_end)
334 _M_token = _S_token_ord_char;
335 _M_value.assign(1, *_M_current++);
337 else if (__c ==
'x' || __c ==
'u')
340 for (
int __i = 0; __i < (__c ==
'x' ? 2 : 4); __i++)
342 if (_M_current == _M_end
343 || !_M_ctype.is(_CtypeT::xdigit, *_M_current))
345 _M_value += *_M_current++;
347 _M_token = _S_token_hex_num;
350 else if (_M_ctype.is(_CtypeT::digit, __c))
352 _M_value.assign(1, __c);
353 while (_M_current != _M_end
354 && _M_ctype.is(_CtypeT::digit, *_M_current))
355 _M_value += *_M_current++;
356 _M_token = _S_token_backref;
360 _M_token = _S_token_ord_char;
361 _M_value.assign(1, __c);
367 template<
typename _CharT>
370 _M_eat_escape_posix()
372 if (_M_current == _M_end)
375 auto __c = *_M_current;
376 auto __pos = std::strchr(_M_spec_char, _M_ctype.narrow(__c,
'\0'));
378 if (__pos !=
nullptr && *__pos !=
'\0')
380 _M_token = _S_token_ord_char;
381 _M_value.assign(1, __c);
384 else if (_M_is_awk())
389 else if (_M_is_basic() && _M_ctype.is(_CtypeT::digit, __c) && __c !=
'0')
391 _M_token = _S_token_backref;
392 _M_value.assign(1, __c);
396 #ifdef __STRICT_ANSI__
400 _M_token = _S_token_ord_char;
401 _M_value.assign(1, __c);
407 template<
typename _CharT>
412 auto __c = *_M_current++;
413 auto __pos = _M_find_escape(_M_ctype.narrow(__c,
'\0'));
415 if (__pos !=
nullptr)
417 _M_token = _S_token_ord_char;
418 _M_value.assign(1, *__pos);
421 else if (_M_ctype.is(_CtypeT::digit, __c)
425 _M_value.assign(1, __c);
428 && _M_current != _M_end
429 && _M_ctype.is(_CtypeT::digit, *_M_current)
430 && *_M_current !=
'8'
431 && *_M_current !=
'9';
433 _M_value += *_M_current++;
434 _M_token = _S_token_oct_num;
444 template<
typename _CharT>
447 _M_eat_class(
char __ch)
449 for (_M_value.clear(); _M_current != _M_end && *_M_current != __ch;)
450 _M_value += *_M_current++;
451 if (_M_current == _M_end
452 || *_M_current++ != __ch
453 || _M_current == _M_end
454 || *_M_current++ !=
']')
463 #ifdef _GLIBCXX_DEBUG
464 template<
typename _CharT>
471 case _S_token_anychar:
472 ostr <<
"any-character\n";
474 case _S_token_backref:
477 case _S_token_bracket_begin:
478 ostr <<
"bracket-begin\n";
480 case _S_token_bracket_neg_begin:
481 ostr <<
"bracket-neg-begin\n";
483 case _S_token_bracket_end:
484 ostr <<
"bracket-end\n";
486 case _S_token_char_class_name:
487 ostr <<
"char-class-name \"" << _M_value <<
"\"\n";
489 case _S_token_closure0:
490 ostr <<
"closure0\n";
492 case _S_token_closure1:
493 ostr <<
"closure1\n";
495 case _S_token_collsymbol:
496 ostr <<
"collsymbol \"" << _M_value <<
"\"\n";
501 case _S_token_dup_count:
502 ostr <<
"dup count: " << _M_value <<
"\n";
507 case _S_token_equiv_class_name:
508 ostr <<
"equiv-class-name \"" << _M_value <<
"\"\n";
510 case _S_token_interval_begin:
511 ostr <<
"interval begin\n";
513 case _S_token_interval_end:
514 ostr <<
"interval end\n";
516 case _S_token_line_begin:
517 ostr <<
"line begin\n";
519 case _S_token_line_end:
520 ostr <<
"line end\n";
528 case _S_token_ord_char:
529 ostr <<
"ordinary character: \"" << _M_value <<
"\"\n";
531 case _S_token_subexpr_begin:
532 ostr <<
"subexpr begin\n";
534 case _S_token_subexpr_no_group_begin:
535 ostr <<
"no grouping subexpr begin\n";
537 case _S_token_subexpr_lookahead_begin:
538 ostr <<
"lookahead subexpr begin\n";
540 case _S_token_subexpr_end:
541 ostr <<
"subexpr end\n";
543 case _S_token_unknown:
544 ostr <<
"-- unknown token --\n";
546 case _S_token_oct_num:
547 ostr <<
"oct number " << _M_value <<
"\n";
549 case _S_token_hex_num:
550 ostr <<
"hex number " << _M_value <<
"\n";
552 case _S_token_quoted_class:
553 ostr <<
"quoted class " <<
"\\" << _M_value <<
"\n";
556 _GLIBCXX_DEBUG_ASSERT(
false);
562 _GLIBCXX_END_NAMESPACE_VERSION
constexpr error_type error_escape(_S_error_escape)
constexpr syntax_option_type nosubs
Container class for localization functionality.The locale class is first a class wrapper for C librar...
constexpr error_type error_collate(_S_error_collate)
constexpr error_type error_ctype(_S_error_ctype)
constexpr error_type error_paren(_S_error_paren)
constexpr error_type error_brace(_S_error_brace)
constexpr error_type error_badbrace(_S_error_badbrace)
constexpr error_type error_brack(_S_error_brack)
const _Facet & use_facet(const locale &__loc)
Return a facet.use_facet looks for and returns a reference to a facet of type Facet where Facet is th...