31 namespace std _GLIBCXX_VISIBILITY(default)
35 _GLIBCXX_BEGIN_NAMESPACE_VERSION
43 typedef long _StateIdT;
44 static const _StateIdT _S_invalid_state_id = -1;
46 template<
typename _CharT>
47 using _Matcher = std::function<bool (_CharT)>;
54 _S_opcode_alternative,
56 _S_opcode_line_begin_assertion,
57 _S_opcode_line_end_assertion,
58 _S_opcode_word_boundary,
59 _S_opcode_subexpr_lookahead,
60 _S_opcode_subexpr_begin,
61 _S_opcode_subexpr_end,
74 size_t _M_backref_index;
78 _StateIdT _M_quant_index;
87 explicit _State_base(
_Opcode __opcode)
88 : _M_opcode(__opcode), _M_next(_S_invalid_state_id)
92 ~_State_base() =
default;
97 _M_print(std::ostream& ostr)
const;
101 _M_dot(std::ostream& __ostr, _StateIdT __id)
const;
105 template<
typename _TraitsT>
106 struct _State : _State_base
108 typedef _Matcher<typename _TraitsT::char_type> _MatcherT;
110 _MatcherT _M_matches;
112 explicit _State(
_Opcode __opcode) : _State_base(__opcode) { }
117 typedef size_t _SizeT;
121 _NFA_base(_FlagT __f)
122 : _M_flags(__f), _M_start_state(0), _M_subexpr_count(0),
123 _M_quant_count(0), _M_has_backref(false)
126 _NFA_base(_NFA_base&&) =
default;
129 ~_NFA_base() =
default;
138 {
return _M_start_state; }
142 {
return _M_subexpr_count; }
146 _StateIdT _M_start_state;
147 _SizeT _M_subexpr_count;
148 _SizeT _M_quant_count;
152 template<
typename _TraitsT>
156 typedef _State<_TraitsT> _StateT;
157 typedef _Matcher<typename _TraitsT::char_type> _MatcherT;
159 using _NFA_base::_NFA_base;
162 _NFA(
const _NFA&) =
delete;
163 _NFA(_NFA&&) =
default;
168 auto __ret = _M_insert_state(_StateT(_S_opcode_accept));
173 _M_insert_alt(_StateIdT __next, _StateIdT __alt,
bool __neg)
175 _StateT __tmp(_S_opcode_alternative);
178 __tmp._M_quant_index = this->_M_quant_count++;
179 __tmp._M_next = __next;
180 __tmp._M_alt = __alt;
181 __tmp._M_neg = __neg;
182 return _M_insert_state(
std::move(__tmp));
186 _M_insert_matcher(_MatcherT __m)
188 _StateT __tmp(_S_opcode_match);
190 return _M_insert_state(
std::move(__tmp));
194 _M_insert_subexpr_begin()
196 auto __id = this->_M_subexpr_count++;
197 this->_M_paren_stack.push_back(__id);
198 _StateT __tmp(_S_opcode_subexpr_begin);
199 __tmp._M_subexpr = __id;
200 return _M_insert_state(
std::move(__tmp));
204 _M_insert_subexpr_end()
206 _StateT __tmp(_S_opcode_subexpr_end);
207 __tmp._M_subexpr = this->_M_paren_stack.back();
208 this->_M_paren_stack.pop_back();
209 return _M_insert_state(
std::move(__tmp));
213 _M_insert_backref(
size_t __index);
216 _M_insert_line_begin()
217 {
return _M_insert_state(_StateT(_S_opcode_line_begin_assertion)); }
221 {
return _M_insert_state(_StateT(_S_opcode_line_end_assertion)); }
224 _M_insert_word_bound(
bool __neg)
226 _StateT __tmp(_S_opcode_word_boundary);
227 __tmp._M_neg = __neg;
228 return _M_insert_state(
std::move(__tmp));
232 _M_insert_lookahead(_StateIdT __alt,
bool __neg)
234 _StateT __tmp(_S_opcode_subexpr_lookahead);
235 __tmp._M_alt = __alt;
236 __tmp._M_neg = __neg;
237 return _M_insert_state(
std::move(__tmp));
242 {
return _M_insert_state(_StateT(_S_opcode_dummy)); }
245 _M_insert_state(_StateT __s)
248 return this->
size()-1;
253 _M_eliminate_dummy();
255 #ifdef _GLIBCXX_DEBUG
257 _M_dot(std::ostream& __ostr)
const;
264 template<
typename _TraitsT>
268 typedef _NFA<_TraitsT> _RegexT;
272 : _M_nfa(__nfa), _M_start(__s), _M_end(__s)
275 _StateSeq(_RegexT& __nfa, _StateIdT __s, _StateIdT __end)
276 : _M_nfa(__nfa), _M_start(__s), _M_end(__end)
281 _M_append(_StateIdT __id)
283 _M_nfa[_M_end]._M_next = __id;
291 _M_nfa[_M_end]._M_next = __s._M_start;
306 _GLIBCXX_END_NAMESPACE_VERSION
310 #include <bits/regex_automaton.tcc>
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
_Opcode
Operation codes that define the type of transitions within the base NFA that represents the regular e...
syntax_option_type
This is a bitmask type indicating how to interpret the regex.
ISO C++ entities toplevel namespace is std.
void push_back(const value_type &__x)
Add data to the end of the vector.
Describes a sequence of one or more _State, its current start and end(s). This structure contains fra...
size_type size() const noexcept