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++;
102 if (std::strchr(_M_spec_char, _M_ctype.narrow(__c,
'\0')) ==
nullptr)
104 _M_token = _S_token_ord_char;
105 _M_value.assign(1, __c);
110 if (_M_current == _M_end)
114 || (*_M_current !=
'('
115 && *_M_current !=
')'
116 && *_M_current !=
'{'))
118 (this->*_M_eat_escape)();
125 if (_M_is_ecma() && *_M_current ==
'?')
127 if (++_M_current == _M_end)
130 if (*_M_current ==
':')
133 _M_token = _S_token_subexpr_no_group_begin;
135 else if (*_M_current ==
'=')
138 _M_token = _S_token_subexpr_lookahead_begin;
139 _M_value.assign(1,
'p');
141 else if (*_M_current ==
'!')
144 _M_token = _S_token_subexpr_lookahead_begin;
145 _M_value.assign(1,
'n');
151 _M_token = _S_token_subexpr_no_group_begin;
153 _M_token = _S_token_subexpr_begin;
156 _M_token = _S_token_subexpr_end;
159 _M_state = _S_state_in_bracket;
160 _M_at_bracket_start =
true;
161 if (_M_current != _M_end && *_M_current ==
'^')
163 _M_token = _S_token_bracket_neg_begin;
167 _M_token = _S_token_bracket_begin;
171 _M_state = _S_state_in_brace;
172 _M_token = _S_token_interval_begin;
174 else if (((__pos = std::strchr(_M_spec_char, _M_ctype.narrow(__c,
'\0')))
179 || (_M_is_grep() && __c ==
'\n'))
181 auto __it = _M_token_tbl;
182 auto __narrowc = _M_ctype.narrow(__c,
'\0');
183 for (; __it->first !=
'\0'; ++__it)
184 if (__it->first == __narrowc)
186 _M_token = __it->second;
189 _GLIBCXX_DEBUG_ASSERT(
false);
193 _M_token = _S_token_ord_char;
194 _M_value.assign(1, __c);
201 template<
typename _CharT>
206 if (_M_current == _M_end)
209 auto __c = *_M_current++;
213 if (_M_current == _M_end)
216 if (*_M_current ==
'.')
218 _M_token = _S_token_collsymbol;
219 _M_eat_class(*_M_current++);
221 else if (*_M_current ==
':')
223 _M_token = _S_token_char_class_name;
224 _M_eat_class(*_M_current++);
226 else if (*_M_current ==
'=')
228 _M_token = _S_token_equiv_class_name;
229 _M_eat_class(*_M_current++);
233 _M_token = _S_token_ord_char;
234 _M_value.assign(1, __c);
240 else if (__c ==
']' && (_M_is_ecma() || !_M_at_bracket_start))
242 _M_token = _S_token_bracket_end;
243 _M_state = _S_state_normal;
246 else if (__c ==
'\\' && (_M_is_ecma() || _M_is_awk()))
247 (this->*_M_eat_escape)();
250 _M_token = _S_token_ord_char;
251 _M_value.assign(1, __c);
253 _M_at_bracket_start =
false;
258 template<
typename _CharT>
263 if (_M_current == _M_end)
266 auto __c = *_M_current++;
268 if (_M_ctype.is(_CtypeT::digit, __c))
270 _M_token = _S_token_dup_count;
271 _M_value.assign(1, __c);
272 while (_M_current != _M_end
273 && _M_ctype.is(_CtypeT::digit, *_M_current))
274 _M_value += *_M_current++;
277 _M_token = _S_token_comma;
279 else if (_M_is_basic())
281 if (__c ==
'\\' && _M_current != _M_end && *_M_current ==
'}')
283 _M_state = _S_state_normal;
284 _M_token = _S_token_interval_end;
292 _M_state = _S_state_normal;
293 _M_token = _S_token_interval_end;
299 template<
typename _CharT>
304 if (_M_current == _M_end)
307 auto __c = *_M_current++;
308 auto __pos = _M_find_escape(_M_ctype.narrow(__c,
'\0'));
310 if (__pos !=
nullptr && (__c !=
'b' || _M_state == _S_state_in_bracket))
312 _M_token = _S_token_ord_char;
313 _M_value.assign(1, *__pos);
317 _M_token = _S_token_word_bound;
318 _M_value.assign(1,
'p');
322 _M_token = _S_token_word_bound;
323 _M_value.assign(1,
'n');
333 _M_token = _S_token_quoted_class;
334 _M_value.assign(1, __c);
338 if (_M_current == _M_end)
340 _M_token = _S_token_ord_char;
341 _M_value.assign(1, *_M_current++);
343 else if (__c ==
'x' || __c ==
'u')
346 for (
int __i = 0; __i < (__c ==
'x' ? 2 : 4); __i++)
348 if (_M_current == _M_end
349 || !_M_ctype.is(_CtypeT::xdigit, *_M_current))
351 _M_value += *_M_current++;
353 _M_token = _S_token_hex_num;
356 else if (_M_ctype.is(_CtypeT::digit, __c))
358 _M_value.assign(1, __c);
359 while (_M_current != _M_end
360 && _M_ctype.is(_CtypeT::digit, *_M_current))
361 _M_value += *_M_current++;
362 _M_token = _S_token_backref;
366 _M_token = _S_token_ord_char;
367 _M_value.assign(1, __c);
373 template<
typename _CharT>
376 _M_eat_escape_posix()
378 if (_M_current == _M_end)
381 auto __c = *_M_current;
382 auto __pos = std::strchr(_M_spec_char, _M_ctype.narrow(__c,
'\0'));
384 if (__pos !=
nullptr && *__pos !=
'\0')
386 _M_token = _S_token_ord_char;
387 _M_value.assign(1, __c);
390 else if (_M_is_awk())
395 else if (_M_is_basic() && _M_ctype.is(_CtypeT::digit, __c) && __c !=
'0')
397 _M_token = _S_token_backref;
398 _M_value.assign(1, __c);
402 #ifdef __STRICT_ANSI__
406 _M_token = _S_token_ord_char;
407 _M_value.assign(1, __c);
413 template<
typename _CharT>
418 auto __c = *_M_current++;
419 auto __pos = _M_find_escape(_M_ctype.narrow(__c,
'\0'));
421 if (__pos !=
nullptr)
423 _M_token = _S_token_ord_char;
424 _M_value.assign(1, *__pos);
427 else if (_M_ctype.is(_CtypeT::digit, __c)
431 _M_value.assign(1, __c);
434 && _M_current != _M_end
435 && _M_ctype.is(_CtypeT::digit, *_M_current)
436 && *_M_current !=
'8'
437 && *_M_current !=
'9';
439 _M_value += *_M_current++;
440 _M_token = _S_token_oct_num;
450 template<
typename _CharT>
453 _M_eat_class(
char __ch)
455 for (_M_value.clear(); _M_current != _M_end && *_M_current != __ch;)
456 _M_value += *_M_current++;
457 if (_M_current == _M_end
458 || *_M_current++ != __ch
459 || _M_current == _M_end
460 || *_M_current++ !=
']')
469 #ifdef _GLIBCXX_DEBUG
470 template<
typename _CharT>
477 case _S_token_anychar:
478 ostr <<
"any-character\n";
480 case _S_token_backref:
483 case _S_token_bracket_begin:
484 ostr <<
"bracket-begin\n";
486 case _S_token_bracket_neg_begin:
487 ostr <<
"bracket-neg-begin\n";
489 case _S_token_bracket_end:
490 ostr <<
"bracket-end\n";
492 case _S_token_char_class_name:
493 ostr <<
"char-class-name \"" << _M_value <<
"\"\n";
495 case _S_token_closure0:
496 ostr <<
"closure0\n";
498 case _S_token_closure1:
499 ostr <<
"closure1\n";
501 case _S_token_collsymbol:
502 ostr <<
"collsymbol \"" << _M_value <<
"\"\n";
507 case _S_token_dup_count:
508 ostr <<
"dup count: " << _M_value <<
"\n";
513 case _S_token_equiv_class_name:
514 ostr <<
"equiv-class-name \"" << _M_value <<
"\"\n";
516 case _S_token_interval_begin:
517 ostr <<
"interval begin\n";
519 case _S_token_interval_end:
520 ostr <<
"interval end\n";
522 case _S_token_line_begin:
523 ostr <<
"line begin\n";
525 case _S_token_line_end:
526 ostr <<
"line end\n";
534 case _S_token_ord_char:
535 ostr <<
"ordinary character: \"" << _M_value <<
"\"\n";
537 case _S_token_subexpr_begin:
538 ostr <<
"subexpr begin\n";
540 case _S_token_subexpr_no_group_begin:
541 ostr <<
"no grouping subexpr begin\n";
543 case _S_token_subexpr_lookahead_begin:
544 ostr <<
"lookahead subexpr begin\n";
546 case _S_token_subexpr_end:
547 ostr <<
"subexpr end\n";
549 case _S_token_unknown:
550 ostr <<
"-- unknown token --\n";
552 case _S_token_oct_num:
553 ostr <<
"oct number " << _M_value <<
"\n";
555 case _S_token_hex_num:
556 ostr <<
"hex number " << _M_value <<
"\n";
558 case _S_token_quoted_class:
559 ostr <<
"quoted class " <<
"\\" << _M_value <<
"\n";
562 _GLIBCXX_DEBUG_ASSERT(
false);
568 _GLIBCXX_END_NAMESPACE_VERSION
constexpr error_type error_ctype(_S_error_ctype)
constexpr error_type error_brace(_S_error_brace)
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...
constexpr error_type error_paren(_S_error_paren)
constexpr syntax_option_type nosubs
constexpr error_type error_escape(_S_error_escape)
constexpr error_type error_badbrace(_S_error_badbrace)
constexpr error_type error_brack(_S_error_brack)
Container class for localization functionality.The locale class is first a class wrapper for C librar...
ISO C++ entities toplevel namespace is std.
constexpr error_type error_collate(_S_error_collate)