| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
// class template regex -*- C++ -*- |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
// Copyright (C) 2013-2015 Free Software Foundation, Inc. |
|
4
|
|
|
|
|
|
|
// |
|
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) |
|
9
|
|
|
|
|
|
|
// any later version. |
|
10
|
|
|
|
|
|
|
|
|
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. |
|
15
|
|
|
|
|
|
|
|
|
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. |
|
19
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
// . |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
/** |
|
26
|
|
|
|
|
|
|
* @file bits/regex_compiler.tcc |
|
27
|
|
|
|
|
|
|
* This is an internal header file, included by other library headers. |
|
28
|
|
|
|
|
|
|
* Do not attempt to use it directly. @headername{regex} |
|
29
|
|
|
|
|
|
|
*/ |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
// FIXME make comments doxygen format. |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
// This compiler refers to "Regular Expression Matching Can Be Simple And Fast" |
|
34
|
|
|
|
|
|
|
// (http://swtch.com/~rsc/regexp/regexp1.html"), |
|
35
|
|
|
|
|
|
|
// but doesn't strictly follow it. |
|
36
|
|
|
|
|
|
|
// |
|
37
|
|
|
|
|
|
|
// When compiling, states are *chained* instead of tree- or graph-constructed. |
|
38
|
|
|
|
|
|
|
// It's more like structured programs: there's if statement and loop statement. |
|
39
|
|
|
|
|
|
|
// |
|
40
|
|
|
|
|
|
|
// For alternative structure (say "a|b"), aka "if statement", two branches |
|
41
|
|
|
|
|
|
|
// should be constructed. However, these two shall merge to an "end_tag" at |
|
42
|
|
|
|
|
|
|
// the end of this operator: |
|
43
|
|
|
|
|
|
|
// |
|
44
|
|
|
|
|
|
|
// branch1 |
|
45
|
|
|
|
|
|
|
// / \ |
|
46
|
|
|
|
|
|
|
// => begin_tag end_tag => |
|
47
|
|
|
|
|
|
|
// \ / |
|
48
|
|
|
|
|
|
|
// branch2 |
|
49
|
|
|
|
|
|
|
// |
|
50
|
|
|
|
|
|
|
// This is the difference between this implementation and that in Russ's |
|
51
|
|
|
|
|
|
|
// article. |
|
52
|
|
|
|
|
|
|
// |
|
53
|
|
|
|
|
|
|
// That's why we introduced dummy node here ------ "end_tag" is a dummy node. |
|
54
|
|
|
|
|
|
|
// All dummy node will be eliminated at the end of compiling process. |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
namespace std _GLIBCXX_VISIBILITY(default) |
|
57
|
|
|
|
|
|
|
{ |
|
58
|
|
|
|
|
|
|
namespace __detail |
|
59
|
|
|
|
|
|
|
{ |
|
60
|
|
|
|
|
|
|
_GLIBCXX_BEGIN_NAMESPACE_VERSION |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
template |
|
63
|
0
|
|
|
|
|
|
_Compiler<_TraitsT>:: |
|
64
|
|
|
|
|
|
|
_Compiler(_IterT __b, _IterT __e, |
|
65
|
|
|
|
|
|
|
const typename _TraitsT::locale_type& __loc, _FlagT __flags) |
|
66
|
|
|
|
|
|
|
: _M_flags((__flags |
|
67
|
0
|
|
|
|
|
|
& (regex_constants::ECMAScript |
|
68
|
|
|
|
|
|
|
| regex_constants::basic |
|
69
|
|
|
|
|
|
|
| regex_constants::extended |
|
70
|
|
|
|
|
|
|
| regex_constants::grep |
|
71
|
|
|
|
|
|
|
| regex_constants::egrep |
|
72
|
|
|
|
|
|
|
| regex_constants::awk)) |
|
73
|
|
|
|
|
|
|
? __flags |
|
74
|
|
|
|
|
|
|
: __flags | regex_constants::ECMAScript), |
|
75
|
|
|
|
|
|
|
_M_scanner(__b, __e, _M_flags, __loc), |
|
76
|
|
|
|
|
|
|
_M_nfa(make_shared<_RegexT>(__loc, _M_flags)), |
|
77
|
0
|
|
|
|
|
|
_M_traits(_M_nfa->_M_traits), |
|
78
|
0
|
0
|
|
|
|
|
_M_ctype(std::use_facet<_CtypeT>(__loc)) |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
{ |
|
80
|
0
|
|
|
|
|
|
_StateSeqT __r(*_M_nfa, _M_nfa->_M_start()); |
|
81
|
0
|
0
|
|
|
|
|
__r._M_append(_M_nfa->_M_insert_subexpr_begin()); |
|
82
|
0
|
0
|
|
|
|
|
this->_M_disjunction(); |
|
83
|
0
|
0
|
|
|
|
|
if (!_M_match_token(_ScannerT::_S_token_eof)) |
|
|
|
0
|
|
|
|
|
|
|
84
|
0
|
0
|
|
|
|
|
__throw_regex_error(regex_constants::error_paren); |
|
85
|
0
|
0
|
|
|
|
|
__r._M_append(_M_pop()); |
|
86
|
|
|
|
|
|
|
_GLIBCXX_DEBUG_ASSERT(_M_stack.empty()); |
|
87
|
0
|
0
|
|
|
|
|
__r._M_append(_M_nfa->_M_insert_subexpr_end()); |
|
88
|
0
|
0
|
|
|
|
|
__r._M_append(_M_nfa->_M_insert_accept()); |
|
89
|
0
|
|
|
|
|
|
_M_nfa->_M_eliminate_dummy(); |
|
90
|
0
|
|
|
|
|
|
} |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
template |
|
93
|
|
|
|
|
|
|
void |
|
94
|
0
|
|
|
|
|
|
_Compiler<_TraitsT>:: |
|
95
|
|
|
|
|
|
|
_M_disjunction() |
|
96
|
|
|
|
|
|
|
{ |
|
97
|
0
|
|
|
|
|
|
this->_M_alternative(); |
|
98
|
0
|
0
|
|
|
|
|
while (_M_match_token(_ScannerT::_S_token_or)) |
|
99
|
|
|
|
|
|
|
{ |
|
100
|
0
|
0
|
|
|
|
|
_StateSeqT __alt1 = _M_pop(); |
|
101
|
0
|
0
|
|
|
|
|
this->_M_alternative(); |
|
102
|
0
|
0
|
|
|
|
|
_StateSeqT __alt2 = _M_pop(); |
|
103
|
0
|
0
|
|
|
|
|
auto __end = _M_nfa->_M_insert_dummy(); |
|
104
|
0
|
|
|
|
|
|
__alt1._M_append(__end); |
|
105
|
0
|
|
|
|
|
|
__alt2._M_append(__end); |
|
106
|
|
|
|
|
|
|
// __alt2 is state._M_next, __alt1 is state._M_alt. The executor |
|
107
|
|
|
|
|
|
|
// executes _M_alt before _M_next, as well as executing left |
|
108
|
|
|
|
|
|
|
// alternative before right one. |
|
109
|
0
|
0
|
|
|
|
|
_M_stack.push(_StateSeqT(*_M_nfa, |
|
|
|
0
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
_M_nfa->_M_insert_alt( |
|
111
|
|
|
|
|
|
|
__alt2._M_start, __alt1._M_start, false), |
|
112
|
|
|
|
|
|
|
__end)); |
|
113
|
|
|
|
|
|
|
} |
|
114
|
0
|
|
|
|
|
|
} |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
template |
|
117
|
|
|
|
|
|
|
void |
|
118
|
0
|
|
|
|
|
|
_Compiler<_TraitsT>:: |
|
119
|
|
|
|
|
|
|
_M_alternative() |
|
120
|
|
|
|
|
|
|
{ |
|
121
|
0
|
0
|
|
|
|
|
if (this->_M_term()) |
|
122
|
|
|
|
|
|
|
{ |
|
123
|
0
|
0
|
|
|
|
|
_StateSeqT __re = _M_pop(); |
|
124
|
0
|
0
|
|
|
|
|
this->_M_alternative(); |
|
125
|
0
|
0
|
|
|
|
|
__re._M_append(_M_pop()); |
|
126
|
0
|
0
|
|
|
|
|
_M_stack.push(__re); |
|
127
|
|
|
|
|
|
|
} |
|
128
|
|
|
|
|
|
|
else |
|
129
|
0
|
0
|
|
|
|
|
_M_stack.push(_StateSeqT(*_M_nfa, _M_nfa->_M_insert_dummy())); |
|
130
|
0
|
|
|
|
|
|
} |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
template |
|
133
|
|
|
|
|
|
|
bool |
|
134
|
0
|
|
|
|
|
|
_Compiler<_TraitsT>:: |
|
135
|
|
|
|
|
|
|
_M_term() |
|
136
|
|
|
|
|
|
|
{ |
|
137
|
0
|
0
|
|
|
|
|
if (this->_M_assertion()) |
|
138
|
0
|
|
|
|
|
|
return true; |
|
139
|
0
|
0
|
|
|
|
|
if (this->_M_atom()) |
|
140
|
|
|
|
|
|
|
{ |
|
141
|
0
|
0
|
|
|
|
|
while (this->_M_quantifier()); |
|
142
|
0
|
|
|
|
|
|
return true; |
|
143
|
|
|
|
|
|
|
} |
|
144
|
0
|
|
|
|
|
|
return false; |
|
145
|
|
|
|
|
|
|
} |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
template |
|
148
|
|
|
|
|
|
|
bool |
|
149
|
0
|
|
|
|
|
|
_Compiler<_TraitsT>:: |
|
150
|
|
|
|
|
|
|
_M_assertion() |
|
151
|
|
|
|
|
|
|
{ |
|
152
|
0
|
0
|
|
|
|
|
if (_M_match_token(_ScannerT::_S_token_line_begin)) |
|
153
|
0
|
0
|
|
|
|
|
_M_stack.push(_StateSeqT(*_M_nfa, _M_nfa->_M_insert_line_begin())); |
|
154
|
0
|
0
|
|
|
|
|
else if (_M_match_token(_ScannerT::_S_token_line_end)) |
|
155
|
0
|
0
|
|
|
|
|
_M_stack.push(_StateSeqT(*_M_nfa, _M_nfa->_M_insert_line_end())); |
|
156
|
0
|
0
|
|
|
|
|
else if (_M_match_token(_ScannerT::_S_token_word_bound)) |
|
157
|
|
|
|
|
|
|
// _M_value[0] == 'n' means it's negative, say "not word boundary". |
|
158
|
0
|
0
|
|
|
|
|
_M_stack.push(_StateSeqT(*_M_nfa, _M_nfa-> |
|
159
|
0
|
|
|
|
|
|
_M_insert_word_bound(_M_value[0] == 'n'))); |
|
160
|
0
|
0
|
|
|
|
|
else if (_M_match_token(_ScannerT::_S_token_subexpr_lookahead_begin)) |
|
161
|
|
|
|
|
|
|
{ |
|
162
|
0
|
0
|
|
|
|
|
auto __neg = _M_value[0] == 'n'; |
|
163
|
0
|
0
|
|
|
|
|
this->_M_disjunction(); |
|
164
|
0
|
0
|
|
|
|
|
if (!_M_match_token(_ScannerT::_S_token_subexpr_end)) |
|
|
|
0
|
|
|
|
|
|
|
165
|
0
|
0
|
|
|
|
|
__throw_regex_error(regex_constants::error_paren); |
|
166
|
0
|
0
|
|
|
|
|
auto __tmp = _M_pop(); |
|
167
|
0
|
0
|
|
|
|
|
__tmp._M_append(_M_nfa->_M_insert_accept()); |
|
168
|
0
|
0
|
|
|
|
|
_M_stack.push( |
|
|
|
0
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
_StateSeqT( |
|
170
|
0
|
|
|
|
|
|
*_M_nfa, |
|
171
|
|
|
|
|
|
|
_M_nfa->_M_insert_lookahead(__tmp._M_start, __neg))); |
|
172
|
|
|
|
|
|
|
} |
|
173
|
|
|
|
|
|
|
else |
|
174
|
0
|
|
|
|
|
|
return false; |
|
175
|
0
|
|
|
|
|
|
return true; |
|
176
|
|
|
|
|
|
|
} |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
template |
|
179
|
|
|
|
|
|
|
bool |
|
180
|
0
|
|
|
|
|
|
_Compiler<_TraitsT>:: |
|
181
|
|
|
|
|
|
|
_M_quantifier() |
|
182
|
|
|
|
|
|
|
{ |
|
183
|
0
|
|
|
|
|
|
bool __neg = (_M_flags & regex_constants::ECMAScript); |
|
184
|
0
|
|
|
|
|
|
auto __init = [this, &__neg]() |
|
185
|
0
|
|
|
|
|
|
{ |
|
186
|
0
|
0
|
|
|
|
|
if (_M_stack.empty()) |
|
187
|
0
|
|
|
|
|
|
__throw_regex_error(regex_constants::error_badrepeat); |
|
188
|
0
|
0
|
|
|
|
|
__neg = __neg && _M_match_token(_ScannerT::_S_token_opt); |
|
|
|
0
|
|
|
|
|
|
|
189
|
0
|
|
|
|
|
|
}; |
|
190
|
0
|
0
|
|
|
|
|
if (_M_match_token(_ScannerT::_S_token_closure0)) |
|
|
|
0
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
{ |
|
192
|
0
|
0
|
|
|
|
|
__init(); |
|
193
|
0
|
0
|
|
|
|
|
auto __e = _M_pop(); |
|
194
|
0
|
|
|
|
|
|
_StateSeqT __r(*_M_nfa, |
|
195
|
|
|
|
|
|
|
_M_nfa->_M_insert_repeat(_S_invalid_state_id, |
|
196
|
0
|
0
|
|
|
|
|
__e._M_start, __neg)); |
|
197
|
0
|
|
|
|
|
|
__e._M_append(__r); |
|
198
|
0
|
0
|
|
|
|
|
_M_stack.push(__r); |
|
199
|
|
|
|
|
|
|
} |
|
200
|
0
|
0
|
|
|
|
|
else if (_M_match_token(_ScannerT::_S_token_closure1)) |
|
|
|
0
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
{ |
|
202
|
0
|
0
|
|
|
|
|
__init(); |
|
203
|
0
|
0
|
|
|
|
|
auto __e = _M_pop(); |
|
204
|
0
|
0
|
|
|
|
|
__e._M_append(_M_nfa->_M_insert_repeat(_S_invalid_state_id, |
|
205
|
|
|
|
|
|
|
__e._M_start, __neg)); |
|
206
|
0
|
0
|
|
|
|
|
_M_stack.push(__e); |
|
207
|
|
|
|
|
|
|
} |
|
208
|
0
|
0
|
|
|
|
|
else if (_M_match_token(_ScannerT::_S_token_opt)) |
|
|
|
0
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
{ |
|
210
|
0
|
0
|
|
|
|
|
__init(); |
|
211
|
0
|
0
|
|
|
|
|
auto __e = _M_pop(); |
|
212
|
0
|
0
|
|
|
|
|
auto __end = _M_nfa->_M_insert_dummy(); |
|
213
|
0
|
|
|
|
|
|
_StateSeqT __r(*_M_nfa, |
|
214
|
|
|
|
|
|
|
_M_nfa->_M_insert_repeat(_S_invalid_state_id, |
|
215
|
0
|
0
|
|
|
|
|
__e._M_start, __neg)); |
|
216
|
0
|
|
|
|
|
|
__e._M_append(__end); |
|
217
|
0
|
|
|
|
|
|
__r._M_append(__end); |
|
218
|
0
|
0
|
|
|
|
|
_M_stack.push(__r); |
|
219
|
|
|
|
|
|
|
} |
|
220
|
0
|
0
|
|
|
|
|
else if (_M_match_token(_ScannerT::_S_token_interval_begin)) |
|
|
|
0
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
{ |
|
222
|
0
|
0
|
|
|
|
|
if (_M_stack.empty()) |
|
223
|
0
|
0
|
|
|
|
|
__throw_regex_error(regex_constants::error_badrepeat); |
|
224
|
0
|
0
|
|
|
|
|
if (!_M_match_token(_ScannerT::_S_token_dup_count)) |
|
|
|
0
|
|
|
|
|
|
|
225
|
0
|
0
|
|
|
|
|
__throw_regex_error(regex_constants::error_badbrace); |
|
226
|
0
|
0
|
|
|
|
|
_StateSeqT __r(_M_pop()); |
|
227
|
0
|
0
|
|
|
|
|
_StateSeqT __e(*_M_nfa, _M_nfa->_M_insert_dummy()); |
|
228
|
0
|
0
|
|
|
|
|
long __min_rep = _M_cur_int_value(10); |
|
229
|
0
|
|
|
|
|
|
bool __infi = false; |
|
230
|
|
|
|
|
|
|
long __n; |
|
231
|
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
// {3 |
|
233
|
0
|
0
|
|
|
|
|
if (_M_match_token(_ScannerT::_S_token_comma)) |
|
|
|
0
|
|
|
|
|
|
|
234
|
0
|
0
|
|
|
|
|
if (_M_match_token(_ScannerT::_S_token_dup_count)) // {3,7} |
|
|
|
0
|
|
|
|
|
|
|
235
|
0
|
0
|
|
|
|
|
__n = _M_cur_int_value(10) - __min_rep; |
|
236
|
|
|
|
|
|
|
else |
|
237
|
0
|
|
|
|
|
|
__infi = true; |
|
238
|
|
|
|
|
|
|
else |
|
239
|
0
|
|
|
|
|
|
__n = 0; |
|
240
|
0
|
0
|
|
|
|
|
if (!_M_match_token(_ScannerT::_S_token_interval_end)) |
|
|
|
0
|
|
|
|
|
|
|
241
|
0
|
0
|
|
|
|
|
__throw_regex_error(regex_constants::error_brace); |
|
242
|
|
|
|
|
|
|
|
|
243
|
0
|
0
|
|
|
|
|
__neg = __neg && _M_match_token(_ScannerT::_S_token_opt); |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
|
|
245
|
0
|
0
|
|
|
|
|
for (long __i = 0; __i < __min_rep; ++__i) |
|
246
|
0
|
0
|
|
|
|
|
__e._M_append(__r._M_clone()); |
|
247
|
|
|
|
|
|
|
|
|
248
|
0
|
0
|
|
|
|
|
if (__infi) |
|
249
|
|
|
|
|
|
|
{ |
|
250
|
0
|
0
|
|
|
|
|
auto __tmp = __r._M_clone(); |
|
251
|
0
|
|
|
|
|
|
_StateSeqT __s(*_M_nfa, |
|
252
|
|
|
|
|
|
|
_M_nfa->_M_insert_repeat(_S_invalid_state_id, |
|
253
|
0
|
0
|
|
|
|
|
__tmp._M_start, __neg)); |
|
254
|
0
|
|
|
|
|
|
__tmp._M_append(__s); |
|
255
|
0
|
|
|
|
|
|
__e._M_append(__s); |
|
256
|
|
|
|
|
|
|
} |
|
257
|
|
|
|
|
|
|
else |
|
258
|
|
|
|
|
|
|
{ |
|
259
|
0
|
0
|
|
|
|
|
if (__n < 0) |
|
260
|
0
|
0
|
|
|
|
|
__throw_regex_error(regex_constants::error_badbrace); |
|
261
|
0
|
0
|
|
|
|
|
auto __end = _M_nfa->_M_insert_dummy(); |
|
262
|
|
|
|
|
|
|
// _M_alt is the "match more" branch, and _M_next is the |
|
263
|
|
|
|
|
|
|
// "match less" one. Switch _M_alt and _M_next of all created |
|
264
|
|
|
|
|
|
|
// nodes. This is a hack but IMO works well. |
|
265
|
0
|
0
|
|
|
|
|
std::stack<_StateIdT> __stack; |
|
|
|
0
|
|
|
|
|
|
|
266
|
0
|
0
|
|
|
|
|
for (long __i = 0; __i < __n; ++__i) |
|
267
|
|
|
|
|
|
|
{ |
|
268
|
0
|
0
|
|
|
|
|
auto __tmp = __r._M_clone(); |
|
269
|
|
|
|
|
|
|
auto __alt = _M_nfa->_M_insert_repeat(__tmp._M_start, |
|
270
|
0
|
0
|
|
|
|
|
__end, __neg); |
|
271
|
0
|
0
|
|
|
|
|
__stack.push(__alt); |
|
272
|
0
|
|
|
|
|
|
__e._M_append(_StateSeqT(*_M_nfa, __alt, __tmp._M_end)); |
|
273
|
|
|
|
|
|
|
} |
|
274
|
0
|
|
|
|
|
|
__e._M_append(__end); |
|
275
|
0
|
0
|
|
|
|
|
while (!__stack.empty()) |
|
276
|
|
|
|
|
|
|
{ |
|
277
|
0
|
|
|
|
|
|
auto& __tmp = (*_M_nfa)[__stack.top()]; |
|
278
|
0
|
|
|
|
|
|
__stack.pop(); |
|
279
|
0
|
|
|
|
|
|
std::swap(__tmp._M_next, __tmp._M_alt); |
|
280
|
|
|
|
|
|
|
} |
|
281
|
|
|
|
|
|
|
} |
|
282
|
0
|
0
|
|
|
|
|
_M_stack.push(__e); |
|
283
|
|
|
|
|
|
|
} |
|
284
|
|
|
|
|
|
|
else |
|
285
|
0
|
|
|
|
|
|
return false; |
|
286
|
0
|
|
|
|
|
|
return true; |
|
287
|
|
|
|
|
|
|
} |
|
288
|
|
|
|
|
|
|
|
|
289
|
|
|
|
|
|
|
#define __INSERT_REGEX_MATCHER(__func, args...)\ |
|
290
|
|
|
|
|
|
|
do\ |
|
291
|
|
|
|
|
|
|
if (!(_M_flags & regex_constants::icase))\ |
|
292
|
|
|
|
|
|
|
if (!(_M_flags & regex_constants::collate))\ |
|
293
|
|
|
|
|
|
|
__func(args);\ |
|
294
|
|
|
|
|
|
|
else\ |
|
295
|
|
|
|
|
|
|
__func(args);\ |
|
296
|
|
|
|
|
|
|
else\ |
|
297
|
|
|
|
|
|
|
if (!(_M_flags & regex_constants::collate))\ |
|
298
|
|
|
|
|
|
|
__func(args);\ |
|
299
|
|
|
|
|
|
|
else\ |
|
300
|
|
|
|
|
|
|
__func(args);\ |
|
301
|
|
|
|
|
|
|
while (false) |
|
302
|
|
|
|
|
|
|
|
|
303
|
|
|
|
|
|
|
template |
|
304
|
|
|
|
|
|
|
bool |
|
305
|
0
|
|
|
|
|
|
_Compiler<_TraitsT>:: |
|
306
|
|
|
|
|
|
|
_M_atom() |
|
307
|
|
|
|
|
|
|
{ |
|
308
|
0
|
0
|
|
|
|
|
if (_M_match_token(_ScannerT::_S_token_anychar)) |
|
309
|
|
|
|
|
|
|
{ |
|
310
|
0
|
0
|
|
|
|
|
if (!(_M_flags & regex_constants::ECMAScript)) |
|
311
|
0
|
0
|
|
|
|
|
__INSERT_REGEX_MATCHER(_M_insert_any_matcher_posix); |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
312
|
|
|
|
|
|
|
else |
|
313
|
0
|
0
|
|
|
|
|
__INSERT_REGEX_MATCHER(_M_insert_any_matcher_ecma); |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
314
|
|
|
|
|
|
|
} |
|
315
|
0
|
0
|
|
|
|
|
else if (_M_try_char()) |
|
316
|
0
|
0
|
|
|
|
|
__INSERT_REGEX_MATCHER(_M_insert_char_matcher); |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
317
|
0
|
0
|
|
|
|
|
else if (_M_match_token(_ScannerT::_S_token_backref)) |
|
318
|
0
|
0
|
|
|
|
|
_M_stack.push(_StateSeqT(*_M_nfa, _M_nfa-> |
|
319
|
0
|
|
|
|
|
|
_M_insert_backref(_M_cur_int_value(10)))); |
|
320
|
0
|
0
|
|
|
|
|
else if (_M_match_token(_ScannerT::_S_token_quoted_class)) |
|
321
|
0
|
0
|
|
|
|
|
__INSERT_REGEX_MATCHER(_M_insert_character_class_matcher); |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
322
|
0
|
0
|
|
|
|
|
else if (_M_match_token(_ScannerT::_S_token_subexpr_no_group_begin)) |
|
323
|
|
|
|
|
|
|
{ |
|
324
|
0
|
0
|
|
|
|
|
_StateSeqT __r(*_M_nfa, _M_nfa->_M_insert_dummy()); |
|
325
|
0
|
0
|
|
|
|
|
this->_M_disjunction(); |
|
326
|
0
|
0
|
|
|
|
|
if (!_M_match_token(_ScannerT::_S_token_subexpr_end)) |
|
|
|
0
|
|
|
|
|
|
|
327
|
0
|
0
|
|
|
|
|
__throw_regex_error(regex_constants::error_paren); |
|
328
|
0
|
0
|
|
|
|
|
__r._M_append(_M_pop()); |
|
329
|
0
|
0
|
|
|
|
|
_M_stack.push(__r); |
|
330
|
|
|
|
|
|
|
} |
|
331
|
0
|
0
|
|
|
|
|
else if (_M_match_token(_ScannerT::_S_token_subexpr_begin)) |
|
332
|
|
|
|
|
|
|
{ |
|
333
|
0
|
0
|
|
|
|
|
_StateSeqT __r(*_M_nfa, _M_nfa->_M_insert_subexpr_begin()); |
|
334
|
0
|
0
|
|
|
|
|
this->_M_disjunction(); |
|
335
|
0
|
0
|
|
|
|
|
if (!_M_match_token(_ScannerT::_S_token_subexpr_end)) |
|
|
|
0
|
|
|
|
|
|
|
336
|
0
|
0
|
|
|
|
|
__throw_regex_error(regex_constants::error_paren); |
|
337
|
0
|
0
|
|
|
|
|
__r._M_append(_M_pop()); |
|
338
|
0
|
0
|
|
|
|
|
__r._M_append(_M_nfa->_M_insert_subexpr_end()); |
|
339
|
0
|
0
|
|
|
|
|
_M_stack.push(__r); |
|
340
|
|
|
|
|
|
|
} |
|
341
|
0
|
0
|
|
|
|
|
else if (!_M_bracket_expression()) |
|
342
|
0
|
|
|
|
|
|
return false; |
|
343
|
0
|
|
|
|
|
|
return true; |
|
344
|
|
|
|
|
|
|
} |
|
345
|
|
|
|
|
|
|
|
|
346
|
|
|
|
|
|
|
template |
|
347
|
|
|
|
|
|
|
bool |
|
348
|
0
|
|
|
|
|
|
_Compiler<_TraitsT>:: |
|
349
|
|
|
|
|
|
|
_M_bracket_expression() |
|
350
|
|
|
|
|
|
|
{ |
|
351
|
|
|
|
|
|
|
bool __neg = |
|
352
|
0
|
|
|
|
|
|
_M_match_token(_ScannerT::_S_token_bracket_neg_begin); |
|
353
|
0
|
0
|
|
|
|
|
if (!(__neg || _M_match_token(_ScannerT::_S_token_bracket_begin))) |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
354
|
0
|
|
|
|
|
|
return false; |
|
355
|
0
|
0
|
|
|
|
|
__INSERT_REGEX_MATCHER(_M_insert_bracket_matcher, __neg); |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
356
|
0
|
|
|
|
|
|
return true; |
|
357
|
|
|
|
|
|
|
} |
|
358
|
|
|
|
|
|
|
#undef __INSERT_REGEX_MATCHER |
|
359
|
|
|
|
|
|
|
|
|
360
|
|
|
|
|
|
|
template |
|
361
|
|
|
|
|
|
|
template |
|
362
|
|
|
|
|
|
|
void |
|
363
|
0
|
|
|
|
|
|
_Compiler<_TraitsT>:: |
|
364
|
|
|
|
|
|
|
_M_insert_any_matcher_ecma() |
|
365
|
|
|
|
|
|
|
{ |
|
366
|
0
|
0
|
|
|
|
|
_M_stack.push(_StateSeqT(*_M_nfa, |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
367
|
|
|
|
|
|
|
_M_nfa->_M_insert_matcher |
|
368
|
|
|
|
|
|
|
(_AnyMatcher<_TraitsT, true, __icase, __collate> |
|
369
|
|
|
|
|
|
|
(_M_traits)))); |
|
370
|
0
|
|
|
|
|
|
} |
|
371
|
|
|
|
|
|
|
|
|
372
|
|
|
|
|
|
|
template |
|
373
|
|
|
|
|
|
|
template |
|
374
|
|
|
|
|
|
|
void |
|
375
|
0
|
|
|
|
|
|
_Compiler<_TraitsT>:: |
|
376
|
|
|
|
|
|
|
_M_insert_any_matcher_posix() |
|
377
|
|
|
|
|
|
|
{ |
|
378
|
0
|
0
|
|
|
|
|
_M_stack.push(_StateSeqT(*_M_nfa, |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
379
|
|
|
|
|
|
|
_M_nfa->_M_insert_matcher |
|
380
|
|
|
|
|
|
|
(_AnyMatcher<_TraitsT, false, __icase, __collate> |
|
381
|
|
|
|
|
|
|
(_M_traits)))); |
|
382
|
0
|
|
|
|
|
|
} |
|
383
|
|
|
|
|
|
|
|
|
384
|
|
|
|
|
|
|
template |
|
385
|
|
|
|
|
|
|
template |
|
386
|
|
|
|
|
|
|
void |
|
387
|
0
|
|
|
|
|
|
_Compiler<_TraitsT>:: |
|
388
|
|
|
|
|
|
|
_M_insert_char_matcher() |
|
389
|
|
|
|
|
|
|
{ |
|
390
|
0
|
0
|
|
|
|
|
_M_stack.push(_StateSeqT(*_M_nfa, |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
391
|
|
|
|
|
|
|
_M_nfa->_M_insert_matcher |
|
392
|
|
|
|
|
|
|
(_CharMatcher<_TraitsT, __icase, __collate> |
|
393
|
0
|
|
|
|
|
|
(_M_value[0], _M_traits)))); |
|
394
|
0
|
|
|
|
|
|
} |
|
395
|
|
|
|
|
|
|
|
|
396
|
|
|
|
|
|
|
template |
|
397
|
|
|
|
|
|
|
template |
|
398
|
|
|
|
|
|
|
void |
|
399
|
0
|
|
|
|
|
|
_Compiler<_TraitsT>:: |
|
400
|
|
|
|
|
|
|
_M_insert_character_class_matcher() |
|
401
|
|
|
|
|
|
|
{ |
|
402
|
|
|
|
|
|
|
_GLIBCXX_DEBUG_ASSERT(_M_value.size() == 1); |
|
403
|
|
|
|
|
|
|
_BracketMatcher<_TraitsT, __icase, __collate> __matcher |
|
404
|
0
|
0
|
|
|
|
|
(_M_ctype.is(_CtypeT::upper, _M_value[0]), _M_traits); |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
405
|
0
|
0
|
|
|
|
|
__matcher._M_add_character_class(_M_value, false); |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
406
|
0
|
0
|
|
|
|
|
__matcher._M_ready(); |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
407
|
0
|
0
|
|
|
|
|
_M_stack.push(_StateSeqT(*_M_nfa, |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
408
|
0
|
|
|
|
|
|
_M_nfa->_M_insert_matcher(std::move(__matcher)))); |
|
409
|
0
|
|
|
|
|
|
} |
|
410
|
|
|
|
|
|
|
|
|
411
|
|
|
|
|
|
|
template |
|
412
|
|
|
|
|
|
|
template |
|
413
|
|
|
|
|
|
|
void |
|
414
|
0
|
|
|
|
|
|
_Compiler<_TraitsT>:: |
|
415
|
|
|
|
|
|
|
_M_insert_bracket_matcher(bool __neg) |
|
416
|
|
|
|
|
|
|
{ |
|
417
|
0
|
0
|
|
|
|
|
_BracketMatcher<_TraitsT, __icase, __collate> __matcher(__neg, _M_traits); |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
418
|
0
|
|
|
|
|
|
pair __last_char; // Optional<_CharT> |
|
419
|
0
|
|
|
|
|
|
__last_char.first = false; |
|
420
|
0
|
0
|
|
|
|
|
if (!(_M_flags & regex_constants::ECMAScript)) |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
421
|
0
|
0
|
|
|
|
|
if (_M_try_char()) |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
422
|
|
|
|
|
|
|
{ |
|
423
|
0
|
0
|
|
|
|
|
__matcher._M_add_char(_M_value[0]); |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
424
|
0
|
|
|
|
|
|
__last_char.first = true; |
|
425
|
0
|
0
|
|
|
|
|
__last_char.second = _M_value[0]; |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
426
|
|
|
|
|
|
|
} |
|
427
|
0
|
0
|
|
|
|
|
while (_M_expression_term(__last_char, __matcher)); |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
428
|
0
|
0
|
|
|
|
|
__matcher._M_ready(); |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
429
|
0
|
0
|
|
|
|
|
_M_stack.push(_StateSeqT( |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
430
|
0
|
|
|
|
|
|
*_M_nfa, |
|
431
|
0
|
|
|
|
|
|
_M_nfa->_M_insert_matcher(std::move(__matcher)))); |
|
432
|
0
|
|
|
|
|
|
} |
|
433
|
|
|
|
|
|
|
|
|
434
|
|
|
|
|
|
|
template |
|
435
|
|
|
|
|
|
|
template |
|
436
|
|
|
|
|
|
|
bool |
|
437
|
0
|
|
|
|
|
|
_Compiler<_TraitsT>:: |
|
438
|
|
|
|
|
|
|
_M_expression_term(pair& __last_char, |
|
439
|
|
|
|
|
|
|
_BracketMatcher<_TraitsT, __icase, __collate>& __matcher) |
|
440
|
|
|
|
|
|
|
{ |
|
441
|
0
|
0
|
|
|
|
|
if (_M_match_token(_ScannerT::_S_token_bracket_end)) |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
442
|
0
|
|
|
|
|
|
return false; |
|
443
|
|
|
|
|
|
|
|
|
444
|
0
|
0
|
|
|
|
|
if (_M_match_token(_ScannerT::_S_token_collsymbol)) |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
445
|
|
|
|
|
|
|
{ |
|
446
|
0
|
0
|
|
|
|
|
auto __symbol = __matcher._M_add_collate_element(_M_value); |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
447
|
0
|
0
|
|
|
|
|
if (__symbol.size() == 1) |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
448
|
|
|
|
|
|
|
{ |
|
449
|
0
|
|
|
|
|
|
__last_char.first = true; |
|
450
|
0
|
0
|
|
|
|
|
__last_char.second = __symbol[0]; |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
451
|
|
|
|
|
|
|
} |
|
452
|
|
|
|
|
|
|
} |
|
453
|
0
|
0
|
|
|
|
|
else if (_M_match_token(_ScannerT::_S_token_equiv_class_name)) |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
454
|
0
|
|
|
|
|
|
__matcher._M_add_equivalence_class(_M_value); |
|
455
|
0
|
0
|
|
|
|
|
else if (_M_match_token(_ScannerT::_S_token_char_class_name)) |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
456
|
0
|
|
|
|
|
|
__matcher._M_add_character_class(_M_value, false); |
|
457
|
|
|
|
|
|
|
// POSIX doesn't allow '-' as a start-range char (say [a-z--0]), |
|
458
|
|
|
|
|
|
|
// except when the '-' is the first or last character in the bracket |
|
459
|
|
|
|
|
|
|
// expression ([--0]). ECMAScript treats all '-' after a range as a |
|
460
|
|
|
|
|
|
|
// normal character. Also see above, where _M_expression_term gets called. |
|
461
|
|
|
|
|
|
|
// |
|
462
|
|
|
|
|
|
|
// As a result, POSIX rejects [-----], but ECMAScript doesn't. |
|
463
|
|
|
|
|
|
|
// Boost (1.57.0) always uses POSIX style even in its ECMAScript syntax. |
|
464
|
|
|
|
|
|
|
// Clang (3.5) always uses ECMAScript style even in its POSIX syntax. |
|
465
|
|
|
|
|
|
|
// |
|
466
|
|
|
|
|
|
|
// It turns out that no one reads BNFs ;) |
|
467
|
0
|
0
|
|
|
|
|
else if (_M_try_char()) |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
468
|
|
|
|
|
|
|
{ |
|
469
|
0
|
0
|
|
|
|
|
if (!__last_char.first) |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
470
|
|
|
|
|
|
|
{ |
|
471
|
0
|
|
|
|
|
|
__matcher._M_add_char(_M_value[0]); |
|
472
|
0
|
0
|
|
|
|
|
if (_M_value[0] == '-' |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
473
|
0
|
|
|
|
|
|
&& !(_M_flags & regex_constants::ECMAScript)) |
|
474
|
|
|
|
|
|
|
{ |
|
475
|
0
|
0
|
|
|
|
|
if (_M_match_token(_ScannerT::_S_token_bracket_end)) |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
476
|
0
|
|
|
|
|
|
return false; |
|
477
|
0
|
|
|
|
|
|
__throw_regex_error(regex_constants::error_range); |
|
478
|
|
|
|
|
|
|
} |
|
479
|
0
|
|
|
|
|
|
__last_char.first = true; |
|
480
|
0
|
|
|
|
|
|
__last_char.second = _M_value[0]; |
|
481
|
|
|
|
|
|
|
} |
|
482
|
|
|
|
|
|
|
else |
|
483
|
|
|
|
|
|
|
{ |
|
484
|
0
|
0
|
|
|
|
|
if (_M_value[0] == '-') |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
485
|
|
|
|
|
|
|
{ |
|
486
|
0
|
0
|
|
|
|
|
if (_M_try_char()) |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
487
|
|
|
|
|
|
|
{ |
|
488
|
0
|
|
|
|
|
|
__matcher._M_make_range(__last_char.second , _M_value[0]); |
|
489
|
0
|
|
|
|
|
|
__last_char.first = false; |
|
490
|
|
|
|
|
|
|
} |
|
491
|
|
|
|
|
|
|
else |
|
492
|
|
|
|
|
|
|
{ |
|
493
|
0
|
|
|
|
|
|
if (_M_scanner._M_get_token() |
|
494
|
0
|
|
|
|
|
|
!= _ScannerT::_S_token_bracket_end) |
|
495
|
0
|
|
|
|
|
|
__throw_regex_error(regex_constants::error_range); |
|
496
|
0
|
|
|
|
|
|
__matcher._M_add_char(_M_value[0]); |
|
497
|
|
|
|
|
|
|
} |
|
498
|
|
|
|
|
|
|
} |
|
499
|
|
|
|
|
|
|
else |
|
500
|
|
|
|
|
|
|
{ |
|
501
|
0
|
|
|
|
|
|
__matcher._M_add_char(_M_value[0]); |
|
502
|
0
|
|
|
|
|
|
__last_char.second = _M_value[0]; |
|
503
|
|
|
|
|
|
|
} |
|
504
|
|
|
|
|
|
|
} |
|
505
|
|
|
|
|
|
|
} |
|
506
|
0
|
0
|
|
|
|
|
else if (_M_match_token(_ScannerT::_S_token_quoted_class)) |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
507
|
0
|
|
|
|
|
|
__matcher._M_add_character_class(_M_value, |
|
508
|
|
|
|
|
|
|
_M_ctype.is(_CtypeT::upper, |
|
509
|
0
|
|
|
|
|
|
_M_value[0])); |
|
510
|
|
|
|
|
|
|
else |
|
511
|
0
|
|
|
|
|
|
__throw_regex_error(regex_constants::error_brack); |
|
512
|
|
|
|
|
|
|
|
|
513
|
0
|
|
|
|
|
|
return true; |
|
514
|
|
|
|
|
|
|
} |
|
515
|
|
|
|
|
|
|
|
|
516
|
|
|
|
|
|
|
template |
|
517
|
|
|
|
|
|
|
bool |
|
518
|
0
|
|
|
|
|
|
_Compiler<_TraitsT>:: |
|
519
|
|
|
|
|
|
|
_M_try_char() |
|
520
|
|
|
|
|
|
|
{ |
|
521
|
0
|
|
|
|
|
|
bool __is_char = false; |
|
522
|
0
|
0
|
|
|
|
|
if (_M_match_token(_ScannerT::_S_token_oct_num)) |
|
523
|
|
|
|
|
|
|
{ |
|
524
|
0
|
|
|
|
|
|
__is_char = true; |
|
525
|
0
|
|
|
|
|
|
_M_value.assign(1, _M_cur_int_value(8)); |
|
526
|
|
|
|
|
|
|
} |
|
527
|
0
|
0
|
|
|
|
|
else if (_M_match_token(_ScannerT::_S_token_hex_num)) |
|
528
|
|
|
|
|
|
|
{ |
|
529
|
0
|
|
|
|
|
|
__is_char = true; |
|
530
|
0
|
|
|
|
|
|
_M_value.assign(1, _M_cur_int_value(16)); |
|
531
|
|
|
|
|
|
|
} |
|
532
|
0
|
0
|
|
|
|
|
else if (_M_match_token(_ScannerT::_S_token_ord_char)) |
|
533
|
0
|
|
|
|
|
|
__is_char = true; |
|
534
|
0
|
|
|
|
|
|
return __is_char; |
|
535
|
|
|
|
|
|
|
} |
|
536
|
|
|
|
|
|
|
|
|
537
|
|
|
|
|
|
|
template |
|
538
|
|
|
|
|
|
|
bool |
|
539
|
0
|
|
|
|
|
|
_Compiler<_TraitsT>:: |
|
540
|
|
|
|
|
|
|
_M_match_token(_TokenT token) |
|
541
|
|
|
|
|
|
|
{ |
|
542
|
0
|
0
|
|
|
|
|
if (token == _M_scanner._M_get_token()) |
|
543
|
|
|
|
|
|
|
{ |
|
544
|
0
|
|
|
|
|
|
_M_value = _M_scanner._M_get_value(); |
|
545
|
0
|
|
|
|
|
|
_M_scanner._M_advance(); |
|
546
|
0
|
|
|
|
|
|
return true; |
|
547
|
|
|
|
|
|
|
} |
|
548
|
0
|
|
|
|
|
|
return false; |
|
549
|
|
|
|
|
|
|
} |
|
550
|
|
|
|
|
|
|
|
|
551
|
|
|
|
|
|
|
template |
|
552
|
|
|
|
|
|
|
int |
|
553
|
0
|
|
|
|
|
|
_Compiler<_TraitsT>:: |
|
554
|
|
|
|
|
|
|
_M_cur_int_value(int __radix) |
|
555
|
|
|
|
|
|
|
{ |
|
556
|
0
|
|
|
|
|
|
long __v = 0; |
|
557
|
0
|
0
|
|
|
|
|
for (typename _StringT::size_type __i = 0; |
|
558
|
0
|
|
|
|
|
|
__i < _M_value.length(); ++__i) |
|
559
|
0
|
|
|
|
|
|
__v =__v * __radix + _M_traits.value(_M_value[__i], __radix); |
|
560
|
0
|
|
|
|
|
|
return __v; |
|
561
|
|
|
|
|
|
|
} |
|
562
|
|
|
|
|
|
|
|
|
563
|
|
|
|
|
|
|
template |
|
564
|
|
|
|
|
|
|
bool |
|
565
|
0
|
|
|
|
|
|
_BracketMatcher<_TraitsT, __icase, __collate>:: |
|
566
|
|
|
|
|
|
|
_M_apply(_CharT __ch, false_type) const |
|
567
|
|
|
|
|
|
|
{ |
|
568
|
0
|
|
|
|
|
|
bool __ret = std::binary_search(_M_char_set.begin(), _M_char_set.end(), |
|
569
|
0
|
0
|
|
|
|
|
_M_translator._M_translate(__ch)); |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
570
|
0
|
0
|
|
|
|
|
if (!__ret) |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
571
|
|
|
|
|
|
|
{ |
|
572
|
0
|
0
|
|
|
|
|
auto __s = _M_translator._M_transform(__ch); |
|
|
|
0
|
|
|
|
|
|
|
573
|
0
|
0
|
|
|
|
|
for (auto& __it : _M_range_set) |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
574
|
0
|
0
|
|
|
|
|
if (__it.first <= __s && __s <= __it.second) |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
575
|
|
|
|
|
|
|
{ |
|
576
|
0
|
|
|
|
|
|
__ret = true; |
|
577
|
0
|
|
|
|
|
|
break; |
|
578
|
|
|
|
|
|
|
} |
|
579
|
0
|
0
|
|
|
|
|
if (_M_traits.isctype(__ch, _M_class_set)) |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
580
|
0
|
|
|
|
|
|
__ret = true; |
|
581
|
0
|
0
|
|
|
|
|
else if (std::find(_M_equiv_set.begin(), _M_equiv_set.end(), |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
582
|
|
|
|
|
|
|
_M_traits.transform_primary(&__ch, &__ch+1)) |
|
583
|
0
|
0
|
|
|
|
|
!= _M_equiv_set.end()) |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
584
|
0
|
|
|
|
|
|
__ret = true; |
|
585
|
|
|
|
|
|
|
else |
|
586
|
|
|
|
|
|
|
{ |
|
587
|
0
|
0
|
|
|
|
|
for (auto& __it : _M_neg_class_set) |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
588
|
0
|
0
|
|
|
|
|
if (!_M_traits.isctype(__ch, __it)) |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
589
|
|
|
|
|
|
|
{ |
|
590
|
0
|
|
|
|
|
|
__ret = true; |
|
591
|
0
|
|
|
|
|
|
break; |
|
592
|
|
|
|
|
|
|
} |
|
593
|
|
|
|
|
|
|
} |
|
594
|
|
|
|
|
|
|
} |
|
595
|
0
|
0
|
|
|
|
|
if (_M_is_non_matching) |
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
596
|
0
|
|
|
|
|
|
return !__ret; |
|
597
|
|
|
|
|
|
|
else |
|
598
|
0
|
|
|
|
|
|
return __ret; |
|
599
|
|
|
|
|
|
|
} |
|
600
|
|
|
|
|
|
|
|
|
601
|
|
|
|
|
|
|
_GLIBCXX_END_NAMESPACE_VERSION |
|
602
|
|
|
|
|
|
|
} // namespace __detail |
|
603
|
|
|
|
|
|
|
} // namespace |