56 enum class _Search_mode :
unsigned char { _BFS = 0, _DFS = 1 };
57 enum class _Match_mode :
unsigned char { _Exact, _Prefix };
62 typedef _GLIBCXX_STD_C::vector<sub_match<_BiIter>, _Alloc> _ResultsVec;
64 typedef typename _TraitsT::char_class_type _ClassT;
65 typedef _NFA<_TraitsT> _NFAT;
68 _Executor(_BiIter __begin,
70 _ResultsVec& __results,
78 _M_nfa(*__re._M_automaton),
79 _M_results(__results),
80 _M_rep_count(_M_nfa.size()),
81 _M_start(_M_nfa._M_start()),
82 _M_visited_states(
nullptr),
84 _M_search_mode(__use_dfs ? _Search_mode::_DFS : _Search_mode::_BFS)
87 if (__flags & match_prev_avail)
88 _M_flags &= ~(match_not_bol | match_not_bow);
89 if (_M_search_mode == _Search_mode::_BFS)
90 _M_visited_states =
new bool[_M_nfa.size()];
94 {
delete[] _M_visited_states; }
100 _M_current = _M_begin;
101 return _M_main(_Match_mode::_Exact);
106 _M_search_from_first()
108 _M_current = _M_begin;
109 return _M_main(_Match_mode::_Prefix);
117 _M_rep_once_more(_Match_mode __match_mode, _StateIdT);
120 _M_handle_repeat(_Match_mode, _StateIdT);
123 _M_handle_subexpr_begin(_Match_mode, _StateIdT);
126 _M_handle_subexpr_end(_Match_mode, _StateIdT);
129 _M_handle_line_begin_assertion(_Match_mode, _StateIdT);
132 _M_handle_line_end_assertion(_Match_mode, _StateIdT);
135 _M_handle_word_boundary(_Match_mode, _StateIdT);
138 _M_handle_subexpr_lookahead(_Match_mode, _StateIdT);
141 _M_handle_match(_Match_mode, _StateIdT);
144 _M_handle_backref(_Match_mode, _StateIdT);
147 _M_handle_accept(_Match_mode, _StateIdT);
150 _M_handle_alternative(_Match_mode, _StateIdT);
153 _M_node(_Match_mode, _StateIdT);
156 _M_dfs(_Match_mode __match_mode, _StateIdT __start);
159 _M_main(_Match_mode __match_mode)
161 if (_M_search_mode == _Search_mode::_DFS)
162 return _M_main_dfs(__match_mode);
164 return _M_main_bfs(__match_mode);
168 _M_main_dfs(_Match_mode __match_mode);
171 _M_main_bfs(_Match_mode __match_mode);
174 _M_is_word(_CharT __ch)
const
176 static const _CharT __s[2] = {
'w' };
177 return _M_re._M_automaton->_M_traits.isctype
178 (__ch, _M_re._M_automaton->_M_traits.lookup_classname(__s, __s+1));
184 if (_M_current == _M_begin)
194 if (_M_match_multiline())
195 return _M_is_line_terminator(*std::prev(_M_current));
202 else if (_M_match_multiline())
203 return _M_is_line_terminator(*std::prev(_M_current));
211 if (_M_current == _M_end)
213 else if (_M_match_multiline())
214 return _M_is_line_terminator(*_M_current);
220 _M_word_boundary()
const;
223 _M_lookahead(_StateIdT __next);
226 _M_is_line_terminator(_CharT __c)
const
228 const auto& __traits = _M_re._M_automaton->_M_traits;
230 const char __n{ __ct.narrow(__c,
' ') };
243 _M_match_multiline()
const noexcept
247 return (_M_re._M_automaton->_M_options() & __m) == __m;
251 _M_visited(_StateIdT __i)
253 if (_M_visited_states)
255 if (_M_visited_states[__i])
257 _M_visited_states[__i] =
true;
262 _BiIter* _M_get_sol_pos() {
return &_M_sol_pos; }
265 _GLIBCXX_STD_C::vector<_ExecutorFrame<_BiIter>> _M_frames;
266 _ResultsVec _M_cur_results;
269 const _BiIter _M_end;
270 const _RegexT& _M_re;
272 _ResultsVec& _M_results;
273 _GLIBCXX_STD_C::vector<pair<_BiIter, int>> _M_rep_count;
278 _GLIBCXX_STD_C::vector<pair<_StateIdT, _ResultsVec>> _M_match_queue;
280 bool* _M_visited_states;
282 const _Search_mode _M_search_mode;