32 #ifndef _GLIBCXX_REGEX_STATE_LIMIT 33 #define _GLIBCXX_REGEX_STATE_LIMIT 100000 36 namespace std _GLIBCXX_VISIBILITY(default)
40 _GLIBCXX_BEGIN_NAMESPACE_VERSION
48 typedef long _StateIdT;
49 static const _StateIdT _S_invalid_state_id = -1;
51 template<
typename _CharT>
52 using _Matcher = std::function<bool (_CharT)>;
59 _S_opcode_alternative,
62 _S_opcode_line_begin_assertion,
63 _S_opcode_line_end_assertion,
64 _S_opcode_word_boundary,
65 _S_opcode_subexpr_lookahead,
66 _S_opcode_subexpr_begin,
67 _S_opcode_subexpr_end,
80 size_t _M_backref_index;
92 explicit _State_base(
_Opcode __opcode)
93 : _M_opcode(__opcode), _M_next(_S_invalid_state_id)
97 ~_State_base() =
default;
100 #ifdef _GLIBCXX_DEBUG 110 template<
typename _TraitsT>
111 struct _State : _State_base
113 typedef _Matcher<typename _TraitsT::char_type> _MatcherT;
115 _MatcherT _M_matches;
117 explicit _State(
_Opcode __opcode) : _State_base(__opcode) { }
122 typedef size_t _SizeT;
126 _NFA_base(_FlagT __f)
127 : _M_flags(__f), _M_start_state(0), _M_subexpr_count(0),
128 _M_has_backref(
false)
131 _NFA_base(_NFA_base&&) =
default;
134 ~_NFA_base() =
default;
143 {
return _M_start_state; }
147 {
return _M_subexpr_count; }
151 _StateIdT _M_start_state;
152 _SizeT _M_subexpr_count;
156 template<
typename _TraitsT>
160 typedef _State<_TraitsT> _StateT;
161 typedef _Matcher<typename _TraitsT::char_type> _MatcherT;
163 _NFA(
const typename _TraitsT::locale_type& __loc, _FlagT __flags)
165 { _M_traits.imbue(__loc); }
168 _NFA(
const _NFA&) =
delete;
169 _NFA(_NFA&&) =
default;
174 auto __ret = _M_insert_state(_StateT(_S_opcode_accept));
179 _M_insert_alt(_StateIdT __next, _StateIdT __alt,
bool __neg)
181 _StateT __tmp(_S_opcode_alternative);
184 __tmp._M_next = __next;
185 __tmp._M_alt = __alt;
186 return _M_insert_state(std::move(__tmp));
190 _M_insert_repeat(_StateIdT __next, _StateIdT __alt,
bool __neg)
192 _StateT __tmp(_S_opcode_repeat);
195 __tmp._M_next = __next;
196 __tmp._M_alt = __alt;
197 __tmp._M_neg = __neg;
198 return _M_insert_state(std::move(__tmp));
202 _M_insert_matcher(_MatcherT __m)
204 _StateT __tmp(_S_opcode_match);
205 __tmp._M_matches = std::move(__m);
206 return _M_insert_state(std::move(__tmp));
210 _M_insert_subexpr_begin()
212 auto __id = this->_M_subexpr_count++;
213 this->_M_paren_stack.push_back(__id);
214 _StateT __tmp(_S_opcode_subexpr_begin);
215 __tmp._M_subexpr = __id;
216 return _M_insert_state(std::move(__tmp));
220 _M_insert_subexpr_end()
222 _StateT __tmp(_S_opcode_subexpr_end);
223 __tmp._M_subexpr = this->_M_paren_stack.back();
224 this->_M_paren_stack.pop_back();
225 return _M_insert_state(std::move(__tmp));
229 _M_insert_backref(
size_t __index);
232 _M_insert_line_begin()
233 {
return _M_insert_state(_StateT(_S_opcode_line_begin_assertion)); }
237 {
return _M_insert_state(_StateT(_S_opcode_line_end_assertion)); }
240 _M_insert_word_bound(
bool __neg)
242 _StateT __tmp(_S_opcode_word_boundary);
243 __tmp._M_neg = __neg;
244 return _M_insert_state(std::move(__tmp));
248 _M_insert_lookahead(_StateIdT __alt,
bool __neg)
250 _StateT __tmp(_S_opcode_subexpr_lookahead);
251 __tmp._M_alt = __alt;
252 __tmp._M_neg = __neg;
253 return _M_insert_state(std::move(__tmp));
258 {
return _M_insert_state(_StateT(_S_opcode_dummy)); }
261 _M_insert_state(_StateT __s)
263 this->push_back(std::move(__s));
264 if (this->size() > _GLIBCXX_REGEX_STATE_LIMIT)
266 return this->size()-1;
271 _M_eliminate_dummy();
273 #ifdef _GLIBCXX_DEBUG 284 template<
typename _TraitsT>
288 typedef _NFA<_TraitsT> _RegexT;
292 : _M_nfa(__nfa), _M_start(__s), _M_end(__s)
295 _StateSeq(_RegexT& __nfa, _StateIdT __s, _StateIdT __end)
296 : _M_nfa(__nfa), _M_start(__s), _M_end(__end)
301 _M_append(_StateIdT __id)
303 _M_nfa[_M_end]._M_next = __id;
311 _M_nfa[_M_end]._M_next = __s._M_start;
326 _GLIBCXX_END_NAMESPACE_VERSION
Describes a sequence of one or more _State, its current start and end(s). This structure contains fra...
syntax_option_type
This is a bitmask type indicating how to interpret the regex.
ISO C++ entities toplevel namespace is std.
_Opcode
Operation codes that define the type of transitions within the base NFA that represents the regular e...
constexpr error_type error_space(_S_error_space)