1 // class template regex -*- C++ -*-
3 // Copyright (C) 2010-2013 Free Software Foundation, Inc.
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 3, or (at your option)
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // Under Section 7 of GPL version 3, you are granted additional
17 // permissions described in the GCC Runtime Library Exception, version
18 // 3.1, as published by the Free Software Foundation.
20 // You should have received a copy of the GNU General Public License and
21 // a copy of the GCC Runtime Library Exception along with this program;
22 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23 // <http://www.gnu.org/licenses/>.
26 * @file bits/regex_compiler.h
27 * This is an internal header file, included by other library headers.
28 * Do not attempt to use it directly. @headername{regex}
31 namespace std _GLIBCXX_VISIBILITY(default)
35 _GLIBCXX_BEGIN_NAMESPACE_VERSION
38 * @addtogroup regex-detail
42 /// Base class for scanner.
45 typedef unsigned int _StateT;
47 static constexpr _StateT _S_state_at_start = 1 << 0;
48 static constexpr _StateT _S_state_in_brace = 1 << 2;
49 static constexpr _StateT _S_state_in_bracket = 1 << 3;
51 virtual ~_Scanner_base() { };
55 * @brief struct _Scanner. Scans an input range for regex tokens.
57 * The %_Scanner class interprets the regular expression pattern in
58 * the input range passed to its constructor as a sequence of parse
59 * tokens passed to the regular expression compiler. The sequence
60 * of tokens provided depends on the flag settings passed to the
61 * constructor: different regular expression grammars will interpret
62 * the same input pattern in syntactically different ways.
64 template<typename _InputIterator>
65 class _Scanner: public _Scanner_base
68 typedef _InputIterator _IteratorT;
69 typedef typename std::iterator_traits<_IteratorT>::value_type _CharT;
70 typedef std::basic_string<_CharT> _StringT;
71 typedef regex_constants::syntax_option_type _FlagT;
72 typedef const std::ctype<_CharT> _CtypeT;
74 /// Token types returned from the scanner.
79 _S_token_bracket_begin,
81 _S_token_inverse_class,
82 _S_token_char_class_name,
85 _S_token_collelem_multi,
86 _S_token_collelem_single,
92 _S_token_equiv_class_name,
93 _S_token_interval_begin,
94 _S_token_interval_end,
100 _S_token_quoted_char,
101 _S_token_subexpr_begin,
102 _S_token_subexpr_end,
108 _Scanner(_IteratorT __begin, _IteratorT __end, _FlagT __flags,
110 : _M_current(__begin) , _M_end(__end) , _M_flags(__flags),
111 _M_ctype(std::use_facet<_CtypeT>(__loc)), _M_state(_S_state_at_start)
119 { return _M_curToken; }
123 { return _M_curValue; }
125 #ifdef _GLIBCXX_DEBUG
127 _M_print(std::ostream&);
138 _M_scan_in_bracket();
149 _IteratorT _M_current;
154 _StringT _M_curValue;
158 template<typename _InputIterator>
160 _Scanner<_InputIterator>::
163 if (_M_current == _M_end)
165 _M_curToken = _S_token_eof;
169 _CharT __c = *_M_current;
170 if (_M_state & _S_state_in_bracket)
172 _M_scan_in_bracket();
175 if (_M_state & _S_state_in_brace)
181 // TODO: re-enable line anchors when _M_assertion is implemented.
182 // See PR libstdc++/47724
183 else if (_M_state & _S_state_at_start && __c == _M_ctype.widen('^'))
185 _M_curToken = _S_token_line_begin;
189 else if (__c == _M_ctype.widen('$'))
191 _M_curToken = _S_token_line_end;
196 else if (__c == _M_ctype.widen('.'))
198 _M_curToken = _S_token_anychar;
202 else if (__c == _M_ctype.widen('*'))
204 _M_curToken = _S_token_closure0;
208 else if (__c == _M_ctype.widen('+'))
210 _M_curToken = _S_token_closure1;
214 else if (__c == _M_ctype.widen('|'))
216 _M_curToken = _S_token_or;
220 else if (__c == _M_ctype.widen('['))
222 _M_curToken = _S_token_bracket_begin;
223 _M_state |= (_S_state_in_bracket | _S_state_at_start);
227 else if (__c == _M_ctype.widen('\\'))
232 else if (!(_M_flags & (regex_constants::basic | regex_constants::grep)))
234 if (__c == _M_ctype.widen('('))
236 _M_curToken = _S_token_subexpr_begin;
240 else if (__c == _M_ctype.widen(')'))
242 _M_curToken = _S_token_subexpr_end;
246 else if (__c == _M_ctype.widen('{'))
248 _M_curToken = _S_token_interval_begin;
249 _M_state |= _S_state_in_brace;
255 _M_curToken = _S_token_ord_char;
256 _M_curValue.assign(1, __c);
261 template<typename _InputIterator>
263 _Scanner<_InputIterator>::
266 if (_M_ctype.is(_CtypeT::digit, *_M_current))
268 _M_curToken = _S_token_dup_count;
269 _M_curValue.assign(1, *_M_current);
271 while (_M_current != _M_end
272 && _M_ctype.is(_CtypeT::digit, *_M_current))
274 _M_curValue += *_M_current;
279 else if (*_M_current == _M_ctype.widen(','))
281 _M_curToken = _S_token_comma;
285 if (_M_flags & (regex_constants::basic | regex_constants::grep))
287 if (*_M_current == _M_ctype.widen('\\'))
292 if (*_M_current == _M_ctype.widen('}'))
294 _M_curToken = _S_token_interval_end;
295 _M_state &= ~_S_state_in_brace;
302 template<typename _InputIterator>
304 _Scanner<_InputIterator>::
307 if (_M_state & _S_state_at_start && *_M_current == _M_ctype.widen('^'))
309 _M_curToken = _S_token_inverse_class;
310 _M_state &= ~_S_state_at_start;
314 else if (*_M_current == _M_ctype.widen('['))
317 if (_M_current == _M_end)
319 _M_curToken = _S_token_eof;
323 if (*_M_current == _M_ctype.widen('.'))
325 _M_curToken = _S_token_collsymbol;
329 else if (*_M_current == _M_ctype.widen(':'))
331 _M_curToken = _S_token_char_class_name;
335 else if (*_M_current == _M_ctype.widen('='))
337 _M_curToken = _S_token_equiv_class_name;
342 else if (*_M_current == _M_ctype.widen('-'))
344 _M_curToken = _S_token_dash;
348 else if (*_M_current == _M_ctype.widen(']'))
350 if (!(_M_flags & regex_constants::ECMAScript)
351 || !(_M_state & _S_state_at_start))
353 // special case: only if _not_ chr first after
354 // '[' or '[^' and if not ECMAscript
355 _M_curToken = _S_token_bracket_end;
360 _M_curToken = _S_token_collelem_single;
361 _M_curValue.assign(1, *_M_current);
365 template<typename _InputIterator>
367 _Scanner<_InputIterator>::
371 if (_M_current == _M_end)
373 _M_curToken = _S_token_eof;
376 _CharT __c = *_M_current;
379 if (__c == _M_ctype.widen('('))
381 if (!(_M_flags & (regex_constants::basic | regex_constants::grep)))
383 _M_curToken = _S_token_ord_char;
384 _M_curValue.assign(1, __c);
387 _M_curToken = _S_token_subexpr_begin;
389 else if (__c == _M_ctype.widen(')'))
391 if (!(_M_flags & (regex_constants::basic | regex_constants::grep)))
393 _M_curToken = _S_token_ord_char;
394 _M_curValue.assign(1, __c);
397 _M_curToken = _S_token_subexpr_end;
399 else if (__c == _M_ctype.widen('{'))
401 if (!(_M_flags & (regex_constants::basic | regex_constants::grep)))
403 _M_curToken = _S_token_ord_char;
404 _M_curValue.assign(1, __c);
408 _M_curToken = _S_token_interval_begin;
409 _M_state |= _S_state_in_brace;
412 else if (__c == _M_ctype.widen('}'))
414 if (!(_M_flags & (regex_constants::basic | regex_constants::grep)))
416 _M_curToken = _S_token_ord_char;
417 _M_curValue.assign(1, __c);
421 if (!(_M_state && _S_state_in_brace))
422 __throw_regex_error(regex_constants::error_badbrace);
423 _M_state &= ~_S_state_in_brace;
424 _M_curToken = _S_token_interval_end;
427 else if (__c == _M_ctype.widen('x'))
430 if (_M_current == _M_end)
432 _M_curToken = _S_token_eof;
435 if (_M_ctype.is(_CtypeT::digit, *_M_current))
437 _M_curValue.assign(1, *_M_current);
439 if (_M_current == _M_end)
441 _M_curToken = _S_token_eof;
444 if (_M_ctype.is(_CtypeT::digit, *_M_current))
446 _M_curValue += *_M_current;
452 else if (__c == _M_ctype.widen('^')
453 || __c == _M_ctype.widen('.')
454 || __c == _M_ctype.widen('*')
455 || __c == _M_ctype.widen('$')
456 || __c == _M_ctype.widen('\\'))
458 _M_curToken = _S_token_ord_char;
459 _M_curValue.assign(1, __c);
461 else if (_M_ctype.is(_CtypeT::digit, __c))
463 _M_curToken = _S_token_backref;
464 _M_curValue.assign(1, __c);
467 __throw_regex_error(regex_constants::error_escape);
471 // Eats a character class or throwns an exception.
472 // current point to ':' delimiter on entry, char after ']' on return
473 template<typename _InputIterator>
475 _Scanner<_InputIterator>::
478 ++_M_current; // skip ':'
479 if (_M_current == _M_end)
480 __throw_regex_error(regex_constants::error_ctype);
481 for (_M_curValue.clear();
482 _M_current != _M_end && *_M_current != _M_ctype.widen(':');
484 _M_curValue += *_M_current;
485 if (_M_current == _M_end)
486 __throw_regex_error(regex_constants::error_ctype);
487 ++_M_current; // skip ':'
488 if (*_M_current != _M_ctype.widen(']'))
489 __throw_regex_error(regex_constants::error_ctype);
490 ++_M_current; // skip ']'
494 template<typename _InputIterator>
496 _Scanner<_InputIterator>::
499 ++_M_current; // skip '='
500 if (_M_current == _M_end)
501 __throw_regex_error(regex_constants::error_collate);
502 for (_M_curValue.clear();
503 _M_current != _M_end && *_M_current != _M_ctype.widen('=');
505 _M_curValue += *_M_current;
506 if (_M_current == _M_end)
507 __throw_regex_error(regex_constants::error_collate);
508 ++_M_current; // skip '='
509 if (*_M_current != _M_ctype.widen(']'))
510 __throw_regex_error(regex_constants::error_collate);
511 ++_M_current; // skip ']'
515 template<typename _InputIterator>
517 _Scanner<_InputIterator>::
520 ++_M_current; // skip '.'
521 if (_M_current == _M_end)
522 __throw_regex_error(regex_constants::error_collate);
523 for (_M_curValue.clear();
524 _M_current != _M_end && *_M_current != _M_ctype.widen('.');
526 _M_curValue += *_M_current;
527 if (_M_current == _M_end)
528 __throw_regex_error(regex_constants::error_collate);
529 ++_M_current; // skip '.'
530 if (*_M_current != _M_ctype.widen(']'))
531 __throw_regex_error(regex_constants::error_collate);
532 ++_M_current; // skip ']'
535 #ifdef _GLIBCXX_DEBUG
536 template<typename _InputIterator>
538 _Scanner<_InputIterator>::
539 _M_print(std::ostream& ostr)
543 case _S_token_anychar:
544 ostr << "any-character\n";
546 case _S_token_backref:
549 case _S_token_bracket_begin:
550 ostr << "bracket-begin\n";
552 case _S_token_bracket_end:
553 ostr << "bracket-end\n";
555 case _S_token_char_class_name:
556 ostr << "char-class-name \"" << _M_curValue << "\"\n";
558 case _S_token_closure0:
559 ostr << "closure0\n";
561 case _S_token_closure1:
562 ostr << "closure1\n";
564 case _S_token_collelem_multi:
565 ostr << "coll-elem-multi \"" << _M_curValue << "\"\n";
567 case _S_token_collelem_single:
568 ostr << "coll-elem-single \"" << _M_curValue << "\"\n";
570 case _S_token_collsymbol:
571 ostr << "collsymbol \"" << _M_curValue << "\"\n";
579 case _S_token_dup_count:
580 ostr << "dup count: " << _M_curValue << "\n";
585 case _S_token_equiv_class_name:
586 ostr << "equiv-class-name \"" << _M_curValue << "\"\n";
588 case _S_token_interval_begin:
589 ostr << "interval begin\n";
591 case _S_token_interval_end:
592 ostr << "interval end\n";
594 case _S_token_line_begin:
595 ostr << "line begin\n";
597 case _S_token_line_end:
598 ostr << "line end\n";
606 case _S_token_ord_char:
607 ostr << "ordinary character: \"" << _M_value() << "\"\n";
609 case _S_token_quoted_char:
610 ostr << "quoted char\n";
612 case _S_token_subexpr_begin:
613 ostr << "subexpr begin\n";
615 case _S_token_subexpr_end:
616 ostr << "subexpr end\n";
618 case _S_token_word_begin:
619 ostr << "word begin\n";
621 case _S_token_word_end:
622 ostr << "word end\n";
624 case _S_token_unknown:
625 ostr << "-- unknown token --\n";
632 /// Builds an NFA from an input iterator interval.
633 template<typename _InIter, typename _TraitsT>
637 typedef _InIter _IterT;
638 typedef typename std::iterator_traits<_InIter>::value_type _CharT;
639 typedef std::basic_string<_CharT> _StringT;
640 typedef regex_constants::syntax_option_type _FlagT;
642 _Compiler(const _InIter& __b, const _InIter& __e,
643 _TraitsT& __traits, _FlagT __flags);
647 { return _M_state_store; }
650 typedef _Scanner<_InIter> _ScannerT;
651 typedef typename _ScannerT::_TokenT _TokenT;
652 typedef std::stack<_StateSeq, std::vector<_StateSeq> > _StackT;
653 typedef _RangeMatcher<_InIter, _TraitsT> _RMatcherT;
655 // accepts a specific token or returns false.
657 _M_match_token(_TokenT __token);
678 _M_bracket_expression();
681 _M_bracket_list(_RMatcherT& __matcher);
684 _M_follow_list(_RMatcherT& __matcher);
687 _M_follow_list2(_RMatcherT& __matcher);
690 _M_expression_term(_RMatcherT& __matcher);
693 _M_range_expression(_RMatcherT& __matcher);
696 _M_start_range(_RMatcherT& __matcher);
699 _M_collating_symbol(_RMatcherT& __matcher);
702 _M_equivalence_class(_RMatcherT& __matcher);
705 _M_character_class(_RMatcherT& __matcher);
708 _M_cur_int_value(int __radix);
711 _ScannerT _M_scanner;
712 _StringT _M_cur_value;
717 template<typename _InIter, typename _TraitsT>
718 _Compiler<_InIter, _TraitsT>::
719 _Compiler(const _InIter& __b, const _InIter& __e, _TraitsT& __traits,
720 _Compiler<_InIter, _TraitsT>::_FlagT __flags)
721 : _M_traits(__traits), _M_scanner(__b, __e, __flags, _M_traits.getloc()),
722 _M_state_store(__flags)
724 typedef _StartTagger<_InIter, _TraitsT> _Start;
725 typedef _EndTagger<_InIter, _TraitsT> _End;
727 _StateSeq __r(_M_state_store,
728 _M_state_store._M_insert_subexpr_begin(_Start(0)));
730 if (!_M_stack.empty())
732 __r._M_append(_M_stack.top());
735 __r._M_append(_M_state_store._M_insert_subexpr_end(0, _End(0)));
736 __r._M_append(_M_state_store._M_insert_accept());
739 template<typename _InIter, typename _TraitsT>
741 _Compiler<_InIter, _TraitsT>::
742 _M_match_token(_Compiler<_InIter, _TraitsT>::_TokenT token)
744 if (token == _M_scanner._M_token())
746 _M_cur_value = _M_scanner._M_value();
747 _M_scanner._M_advance();
753 template<typename _InIter, typename _TraitsT>
755 _Compiler<_InIter, _TraitsT>::
758 this->_M_alternative();
759 if (_M_match_token(_ScannerT::_S_token_or))
761 _StateSeq __alt1 = _M_stack.top(); _M_stack.pop();
762 this->_M_disjunction();
763 _StateSeq __alt2 = _M_stack.top(); _M_stack.pop();
764 _M_stack.push(_StateSeq(__alt1, __alt2));
768 template<typename _InIter, typename _TraitsT>
770 _Compiler<_InIter, _TraitsT>::
775 _StateSeq __re = _M_stack.top(); _M_stack.pop();
776 this->_M_alternative();
777 if (!_M_stack.empty())
779 __re._M_append(_M_stack.top());
788 template<typename _InIter, typename _TraitsT>
790 _Compiler<_InIter, _TraitsT>::
793 if (this->_M_assertion())
797 this->_M_quantifier();
803 template<typename _InIter, typename _TraitsT>
805 _Compiler<_InIter, _TraitsT>::
808 if (_M_match_token(_ScannerT::_S_token_line_begin))
810 // __m.push(_Matcher::_S_opcode_line_begin);
813 if (_M_match_token(_ScannerT::_S_token_line_end))
815 // __m.push(_Matcher::_S_opcode_line_end);
818 if (_M_match_token(_ScannerT::_S_token_word_begin))
820 // __m.push(_Matcher::_S_opcode_word_begin);
823 if (_M_match_token(_ScannerT::_S_token_word_end))
825 // __m.push(_Matcher::_S_opcode_word_end);
831 template<typename _InIter, typename _TraitsT>
833 _Compiler<_InIter, _TraitsT>::
836 if (_M_match_token(_ScannerT::_S_token_closure0))
838 if (_M_stack.empty())
839 __throw_regex_error(regex_constants::error_badrepeat);
840 _StateSeq __r(_M_stack.top(), -1);
841 __r._M_append(__r._M_front());
846 if (_M_match_token(_ScannerT::_S_token_closure1))
848 if (_M_stack.empty())
849 __throw_regex_error(regex_constants::error_badrepeat);
850 _StateSeq __r(_M_state_store,
852 _M_insert_alt(_S_invalid_state_id,
853 _M_stack.top()._M_front()));
854 _M_stack.top()._M_append(__r);
857 if (_M_match_token(_ScannerT::_S_token_opt))
859 if (_M_stack.empty())
860 __throw_regex_error(regex_constants::error_badrepeat);
861 _StateSeq __r(_M_stack.top(), -1);
866 if (_M_match_token(_ScannerT::_S_token_interval_begin))
868 if (_M_stack.empty())
869 __throw_regex_error(regex_constants::error_badrepeat);
870 if (!_M_match_token(_ScannerT::_S_token_dup_count))
871 __throw_regex_error(regex_constants::error_badbrace);
872 _StateSeq __r(_M_stack.top());
873 int __min_rep = _M_cur_int_value(10);
874 for (int __i = 1; __i < __min_rep; ++__i)
875 _M_stack.top()._M_append(__r._M_clone());
876 if (_M_match_token(_ScannerT::_S_token_comma))
877 if (_M_match_token(_ScannerT::_S_token_dup_count))
879 int __n = _M_cur_int_value(10) - __min_rep;
881 __throw_regex_error(regex_constants::error_badbrace);
882 for (int __i = 0; __i < __n; ++__i)
884 _StateSeq __r(_M_state_store,
886 _M_insert_alt(_S_invalid_state_id,
887 _M_stack.top()._M_front()));
888 _M_stack.top()._M_append(__r);
893 _StateSeq __r(_M_stack.top(), -1);
894 __r._M_push_back(__r._M_front());
898 if (!_M_match_token(_ScannerT::_S_token_interval_end))
899 __throw_regex_error(regex_constants::error_brace);
905 template<typename _InIter, typename _TraitsT>
907 _Compiler<_InIter, _TraitsT>::
910 typedef _CharMatcher<_InIter, _TraitsT> _CMatcher;
911 typedef _StartTagger<_InIter, _TraitsT> _Start;
912 typedef _EndTagger<_InIter, _TraitsT> _End;
914 if (_M_match_token(_ScannerT::_S_token_anychar))
916 _M_stack.push(_StateSeq(_M_state_store,
917 _M_state_store._M_insert_matcher
921 if (_M_match_token(_ScannerT::_S_token_ord_char))
923 _M_stack.push(_StateSeq(_M_state_store,
924 _M_state_store._M_insert_matcher
925 (_CMatcher(_M_cur_value[0], _M_traits))));
928 if (_M_match_token(_ScannerT::_S_token_quoted_char))
930 // note that in the ECMA grammar, this case covers backrefs.
931 _M_stack.push(_StateSeq(_M_state_store,
932 _M_state_store._M_insert_matcher
933 (_CMatcher(_M_cur_value[0], _M_traits))));
936 if (_M_match_token(_ScannerT::_S_token_backref))
938 // __m.push(_Matcher::_S_opcode_ordchar, _M_cur_value);
941 if (_M_match_token(_ScannerT::_S_token_subexpr_begin))
943 int __mark = _M_state_store._M_sub_count();
944 _StateSeq __r(_M_state_store,
946 _M_insert_subexpr_begin(_Start(__mark)));
947 this->_M_disjunction();
948 if (!_M_match_token(_ScannerT::_S_token_subexpr_end))
949 __throw_regex_error(regex_constants::error_paren);
950 if (!_M_stack.empty())
952 __r._M_append(_M_stack.top());
955 __r._M_append(_M_state_store._M_insert_subexpr_end
956 (__mark, _End(__mark)));
960 return _M_bracket_expression();
963 template<typename _InIter, typename _TraitsT>
965 _Compiler<_InIter, _TraitsT>::
966 _M_bracket_expression()
968 if (_M_match_token(_ScannerT::_S_token_bracket_begin))
970 _RMatcherT __matcher(_M_match_token(_ScannerT::_S_token_line_begin),
972 if (!_M_bracket_list(__matcher)
973 || !_M_match_token(_ScannerT::_S_token_bracket_end))
974 __throw_regex_error(regex_constants::error_brack);
975 _M_stack.push(_StateSeq(_M_state_store,
976 _M_state_store._M_insert_matcher(__matcher)));
982 // If the dash is the last character in the bracket expression, it is not
984 template<typename _InIter, typename _TraitsT>
986 _Compiler<_InIter, _TraitsT>::
987 _M_bracket_list(_RMatcherT& __matcher)
989 if (_M_follow_list(__matcher))
991 if (_M_match_token(_ScannerT::_S_token_dash))
992 __matcher._M_add_char(_M_cur_value[0]);
998 template<typename _InIter, typename _TraitsT>
1000 _Compiler<_InIter, _TraitsT>::
1001 _M_follow_list(_RMatcherT& __matcher)
1002 { return _M_expression_term(__matcher) && _M_follow_list2(__matcher); }
1004 template<typename _InIter, typename _TraitsT>
1006 _Compiler<_InIter, _TraitsT>::
1007 _M_follow_list2(_RMatcherT& __matcher)
1009 if (_M_expression_term(__matcher))
1010 return _M_follow_list2(__matcher);
1014 template<typename _InIter, typename _TraitsT>
1016 _Compiler<_InIter, _TraitsT>::
1017 _M_expression_term(_RMatcherT& __matcher)
1019 return (_M_collating_symbol(__matcher)
1020 || _M_character_class(__matcher)
1021 || _M_equivalence_class(__matcher)
1022 || (_M_start_range(__matcher)
1023 && _M_range_expression(__matcher)));
1026 template<typename _InIter, typename _TraitsT>
1028 _Compiler<_InIter, _TraitsT>::
1029 _M_range_expression(_RMatcherT& __matcher)
1031 if (!_M_collating_symbol(__matcher))
1032 if (!_M_match_token(_ScannerT::_S_token_dash))
1033 __throw_regex_error(regex_constants::error_range);
1034 __matcher._M_make_range();
1038 template<typename _InIter, typename _TraitsT>
1040 _Compiler<_InIter, _TraitsT>::
1041 _M_start_range(_RMatcherT& __matcher)
1042 { return _M_match_token(_ScannerT::_S_token_dash); }
1044 template<typename _InIter, typename _TraitsT>
1046 _Compiler<_InIter, _TraitsT>::
1047 _M_collating_symbol(_RMatcherT& __matcher)
1049 if (_M_match_token(_ScannerT::_S_token_collelem_single))
1051 __matcher._M_add_char(_M_cur_value[0]);
1054 if (_M_match_token(_ScannerT::_S_token_collsymbol))
1056 __matcher._M_add_collating_element(_M_cur_value);
1062 template<typename _InIter, typename _TraitsT>
1064 _Compiler<_InIter, _TraitsT>::
1065 _M_equivalence_class(_RMatcherT& __matcher)
1067 if (_M_match_token(_ScannerT::_S_token_equiv_class_name))
1069 __matcher._M_add_equivalence_class(_M_cur_value);
1075 template<typename _InIter, typename _TraitsT>
1077 _Compiler<_InIter, _TraitsT>::
1078 _M_character_class(_RMatcherT& __matcher)
1080 if (_M_match_token(_ScannerT::_S_token_char_class_name))
1082 __matcher._M_add_character_class(_M_cur_value);
1088 template<typename _InIter, typename _TraitsT>
1090 _Compiler<_InIter, _TraitsT>::
1091 _M_cur_int_value(int __radix)
1094 for (typename _StringT::size_type __i = 0;
1095 __i < _M_cur_value.length(); ++__i)
1096 __v =__v * __radix + _M_traits.value(_M_cur_value[__i], __radix);
1100 template<typename _InIter, typename _TraitsT>
1102 __compile(const _InIter& __b, const _InIter& __e, _TraitsT& __t,
1103 regex_constants::syntax_option_type __f)
1104 { return _AutomatonPtr(new _Nfa(_Compiler<_InIter, _TraitsT>(__b, __e, __t,
1108 _GLIBCXX_END_NAMESPACE_VERSION
1109 } // namespace __detail