31 namespace std _GLIBCXX_VISIBILITY(default)
35 _GLIBCXX_BEGIN_NAMESPACE_VERSION
46 typedef unsigned int _SizeT;
53 _M_sub_count()
const = 0;
57 _M_dot(std::ostream& __ostr)
const = 0;
68 _S_opcode_unknown = 0,
69 _S_opcode_alternative = 1,
70 _S_opcode_subexpr_begin = 4,
71 _S_opcode_subexpr_end = 5,
72 _S_opcode_match = 100,
73 _S_opcode_accept = 255
79 virtual void _M_set_pos(
int __i,
int __j,
const _PatternCursor& __p) = 0;
80 virtual void _M_set_matched(
int __i,
bool __is_matched) = 0;
84 typedef std::function<void (const _PatternCursor&, _Results&)>
_Tagger;
87 template<
typename _FwdIterT,
typename _TraitsT>
97 { __r._M_set_pos(_M_index, 0, __pc); }
103 template<
typename _FwdIterT,
typename _TraitsT>
113 { __r._M_set_pos(_M_index, 1, __pc); }
120 typedef std::function<bool (const _PatternCursor&)>
_Matcher;
128 template<
typename _InIterT,
typename _TraitsT>
131 typedef typename _TraitsT::char_type char_type;
134 _CharMatcher(char_type __c,
const _TraitsT& __t = _TraitsT())
135 : _M_traits(__t), _M_c(_M_traits.translate(__c))
142 _CursorT __c =
static_cast<_CursorT
>(__pc);
143 return _M_traits.translate(__c._M_current()) == _M_c;
146 const _TraitsT& _M_traits;
151 template<
typename _InIterT,
typename _TraitsT>
154 typedef typename _TraitsT::char_type _CharT;
158 _RangeMatcher(
bool __is_non_matching,
const _TraitsT& __t = _TraitsT())
159 : _M_traits(__t), _M_is_non_matching(__is_non_matching)
166 _CursorT __c =
static_cast<_CursorT
>(__pc);
171 _M_add_char(_CharT __c)
175 _M_add_collating_element(
const _StringT& __s)
179 _M_add_equivalence_class(
const _StringT& __s)
183 _M_add_character_class(
const _StringT& __s)
190 const _TraitsT& _M_traits;
191 bool _M_is_non_matching;
213 typedef int _OpcodeT;
218 unsigned int _M_subexpr;
222 explicit _State(_OpcodeT __opcode)
223 : _M_opcode(__opcode), _M_next(_S_invalid_state_id)
226 _State(
const _Matcher& __m)
227 : _M_opcode(_S_opcode_match), _M_next(_S_invalid_state_id), _M_matches(__m)
230 _State(_OpcodeT __opcode,
unsigned int __s,
const _Tagger& __t)
231 : _M_opcode(__opcode), _M_next(_S_invalid_state_id), _M_subexpr(__s),
235 _State(_StateIdT __next, _StateIdT __alt)
236 : _M_opcode(_S_opcode_alternative), _M_next(__next), _M_alt(__alt)
239 #ifdef _GLIBCXX_DEBUG
241 _M_print(std::ostream& ostr)
const;
245 _M_dot(std::ostream& __ostr, _StateIdT __id)
const;
274 typedef unsigned int _SizeT;
278 : _M_flags(__f), _M_start_state(0), _M_subexpr_count(0)
290 {
return _M_start_state; }
293 _M_final_states()
const
294 {
return _M_accepting_states; }
298 {
return _M_subexpr_count; }
303 this->
push_back(_StateT(_S_opcode_accept));
305 return this->
size()-1;
309 _M_insert_alt(_StateIdT __next, _StateIdT __alt)
312 return this->
size()-1;
316 _M_insert_matcher(_Matcher __m)
319 return this->
size()-1;
323 _M_insert_subexpr_begin(
const _Tagger& __t)
325 this->
push_back(_StateT(_S_opcode_subexpr_begin, _M_subexpr_count++,
327 return this->
size()-1;
331 _M_insert_subexpr_end(
unsigned int __i,
const _Tagger& __t)
333 this->
push_back(_StateT(_S_opcode_subexpr_end, __i, __t));
334 return this->
size()-1;
337 #ifdef _GLIBCXX_DEBUG
339 _M_dot(std::ostream& __ostr)
const;
344 _StateIdT _M_start_state;
345 _StateSet _M_accepting_states;
346 _SizeT _M_subexpr_count;
356 _StateSeq(
_Nfa& __ss, _StateIdT __s, _StateIdT __e = _S_invalid_state_id)
357 : _M_nfa(__ss), _M_start(__s), _M_end1(__s), _M_end2(__e)
361 : _M_nfa(__e1._M_nfa),
362 _M_start(_M_nfa._M_insert_alt(__e1._M_start, __e2._M_start)),
363 _M_end1(__e1._M_end1), _M_end2(__e2._M_end1)
368 : _M_nfa(__e._M_nfa),
369 _M_start(_M_nfa._M_insert_alt(__id, __e._M_start)),
370 _M_end1(__id), _M_end2(__e._M_end1)
375 : _M_nfa(__rhs._M_nfa), _M_start(__rhs._M_start),
376 _M_end1(__rhs._M_end1), _M_end2(__rhs._M_end2)
388 _M_push_back(_StateIdT __id);
392 _M_append(_StateIdT __id);
410 _GLIBCXX_END_NAMESPACE_VERSION
414 #include <bits/regex_nfa.tcc>
void push_back(const value_type &__x)
Add data to the end of the vector.
A standard container which offers fixed time access to individual elements in any order...
Matches a single character.
ABC for pattern matching.
Provides a generic facade for a templated match_results.
Base class for, um, automata. Could be an NFA or a DFA. Your choice.
std::pair< iterator, bool > insert(const value_type &__x)
Attempts to insert an element into the set.
_Opcode
Operation codes that define the type of transitions within the base NFA that represents the regular e...
static const _StateIdT _S_invalid_state_id
The special case in which a state identifier is not an index.
ISO C++ entities toplevel namespace is std.
Describes a sequence of one or more _State, its current start and end(s). This structure contains fra...
std::function< void(const _PatternCursor &, _Results &)> _Tagger
Tags current state (for subexpr begin/end).
std::shared_ptr< _Automaton > _AutomatonPtr
Generic shared pointer to an automaton.
Matches a character range (bracket expression)
bool _AnyMatcher(const _PatternCursor &)
Matches any character.
unsigned int syntax_option_type
This is a bitmask type indicating how to interpret the regex.
Provides a cursor into the specific target string.
std::set< _StateIdT > _StateSet
The Grep Matcher works on sets of states. Here are sets of states.
size_type size() const noexcept
int _StateIdT
Identifies a state in the NFA.
std::function< bool(const _PatternCursor &)> _Matcher
Indicates if current state matches cursor current.