31 namespace std _GLIBCXX_VISIBILITY(default)
35 _GLIBCXX_BEGIN_NAMESPACE_VERSION
37 template<
typename _BiIter,
typename _Alloc,
typename _TraitsT,
39 bool _Executor<_BiIter, _Alloc, _TraitsT, __dfs_mode>::
43 return _M_search_from_first();
44 auto __cur = _M_begin;
52 while (__cur++ != _M_end);
99 template<
typename _BiIter,
typename _Alloc,
typename _TraitsT,
101 template<
bool __match_mode>
102 bool _Executor<_BiIter, _Alloc, _TraitsT, __dfs_mode>::
108 _M_cur_results = _M_results;
109 _M_dfs<__match_mode>(_M_start_state);
114 _M_match_queue->push(
make_pair(_M_start_state, _M_results));
119 if (_M_match_queue->empty())
121 _M_visited->assign(_M_visited->size(),
false);
122 auto _M_old_queue = std::move(*_M_match_queue);
123 while (!_M_old_queue.empty())
125 auto __task = _M_old_queue.front();
127 _M_cur_results = __task.second;
128 _M_dfs<__match_mode>(__task.first);
132 if (_M_current == _M_end)
143 template<
typename _BiIter,
typename _Alloc,
typename _TraitsT,
145 bool _Executor<_BiIter, _Alloc, _TraitsT, __dfs_mode>::
146 _M_lookahead(_State<_TraitsT> __state)
148 _ResultsVec __what(_M_cur_results.size());
154 __sub->_M_start_state = __state._M_alt;
155 if (__sub->_M_search_from_first())
157 for (
size_t __i = 0; __i < __what.size(); __i++)
158 if (__what[__i].matched)
159 _M_cur_results[__i] = __what[__i];
166 template<
typename _BiIter,
typename _Alloc,
typename _TraitsT,
168 template<
bool __match_mode>
169 void _Executor<_BiIter, _Alloc, _TraitsT, __dfs_mode>::
170 _M_dfs(_StateIdT __i)
174 if ((*_M_visited)[__i])
176 (*_M_visited)[__i] =
true;
179 const auto& __state = _M_nfa[__i];
182 switch (__state._M_opcode)
188 case _S_opcode_alternative:
193 _M_dfs<__match_mode>(__state._M_alt);
195 if (!__dfs_mode || !_M_has_sol)
196 _M_dfs<__match_mode>(__state._M_next);
203 _M_dfs<__match_mode>(__state._M_next);
205 _M_dfs<__match_mode>(__state._M_alt);
214 _M_dfs<__match_mode>(__state._M_next);
219 _M_dfs<__match_mode>(__state._M_alt);
224 case _S_opcode_subexpr_begin:
228 if (!_M_cur_results[__state._M_subexpr].matched
229 || _M_cur_results[__state._M_subexpr].first != _M_current)
231 auto& __res = _M_cur_results[__state._M_subexpr];
232 auto __back = __res.first;
233 __res.first = _M_current;
234 _M_dfs<__match_mode>(__state._M_next);
235 __res.first = __back;
238 case _S_opcode_subexpr_end:
239 if (_M_cur_results[__state._M_subexpr].second != _M_current
240 || _M_cur_results[__state._M_subexpr].matched !=
true)
242 auto& __res = _M_cur_results[__state._M_subexpr];
244 __res.second = _M_current;
245 __res.matched =
true;
246 _M_dfs<__match_mode>(__state._M_next);
250 _M_dfs<__match_mode>(__state._M_next);
252 case _S_opcode_line_begin_assertion:
254 _M_dfs<__match_mode>(__state._M_next);
256 case _S_opcode_line_end_assertion:
258 _M_dfs<__match_mode>(__state._M_next);
260 case _S_opcode_word_boundary:
261 if (_M_word_boundary(__state) == !__state._M_neg)
262 _M_dfs<__match_mode>(__state._M_next);
266 case _S_opcode_subexpr_lookahead:
267 if (_M_lookahead(__state) == !__state._M_neg)
268 _M_dfs<__match_mode>(__state._M_next);
270 case _S_opcode_match:
273 if (_M_current != _M_end && __state._M_matches(*_M_current))
276 _M_dfs<__match_mode>(__state._M_next);
281 if (__state._M_matches(*_M_current))
282 _M_match_queue->push(
make_pair(__state._M_next, _M_cur_results));
288 case _S_opcode_backref:
290 _GLIBCXX_DEBUG_ASSERT(__dfs_mode);
291 auto& __submatch = _M_cur_results[__state._M_backref_index];
292 if (!__submatch.matched)
294 auto __last = _M_current;
295 for (
auto __tmp = __submatch.first;
296 __last != _M_end && __tmp != __submatch.second;
299 if (_M_re._M_traits.transform(__submatch.first,
301 == _M_re._M_traits.transform(_M_current, __last))
303 if (__last != _M_current)
305 auto __backup = _M_current;
307 _M_dfs<__match_mode>(__state._M_next);
308 _M_current = __backup;
311 _M_dfs<__match_mode>(__state._M_next);
315 case _S_opcode_accept:
318 _GLIBCXX_DEBUG_ASSERT(!_M_has_sol);
320 _M_has_sol = _M_current == _M_end;
323 if (_M_current == _M_begin
327 _M_results = _M_cur_results;
331 if (_M_current == _M_begin
332 && (_M_flags & regex_constants::match_not_null))
334 if (!__match_mode || _M_current == _M_end)
338 _M_results = _M_cur_results;
343 _GLIBCXX_DEBUG_ASSERT(
false);
348 template<
typename _BiIter,
typename _Alloc,
typename _TraitsT,
350 bool _Executor<_BiIter, _Alloc, _TraitsT, __dfs_mode>::
351 _M_word_boundary(_State<_TraitsT> __state)
const
355 auto __pre = _M_current;
357 if (!(_M_at_begin() && _M_at_end()))
360 __ans = _M_is_word(*_M_current)
362 else if (_M_at_end())
363 __ans = _M_is_word(*__pre)
366 __ans = _M_is_word(*_M_current)
367 != _M_is_word(*__pre);
372 _GLIBCXX_END_NAMESPACE_VERSION
20.7.1.2 unique_ptr for single objects.
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.