35 _GLIBCXX_BEGIN_NAMESPACE_VERSION
46 typedef unsigned int _SizeT;
53 _M_sub_count()
const = 0;
57 _M_dot(std::ostream& __ostr)
const = 0;
62 typedef std::shared_ptr<_Automaton> _AutomatonPtr;
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>
96 operator()(
const _PatternCursor& __pc, _Results& __r)
97 { __r._M_set_pos(_M_index, 0, __pc); }
103 template<
typename _FwdIterT,
typename _TraitsT>
112 operator()(
const _PatternCursor& __pc, _Results& __r)
113 { __r._M_set_pos(_M_index, 1, __pc); }
120 typedef std::function<bool (const _PatternCursor&)> _Matcher;
124 _AnyMatcher(
const _PatternCursor&)
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))
139 operator()(
const _PatternCursor& __pc)
const
141 typedef const _SpecializedCursor<_InIterT>& _CursorT;
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;
155 typedef std::basic_string<_CharT> _StringT;
158 _RangeMatcher(
bool __is_non_matching,
const _TraitsT& __t = _TraitsT())
159 : _M_traits(__t), _M_is_non_matching(__is_non_matching)
163 operator()(
const _PatternCursor& __pc)
const
165 typedef const _SpecializedCursor<_InIterT>& _CursorT;
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;
195 typedef int _StateIdT;
198 static const _StateIdT _S_invalid_state_id = -1;
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;
251 typedef std::set<_StateIdT> _StateSet;
270 :
public _Automaton,
public std::vector<_State>
273 typedef _State _StateT;
274 typedef unsigned int _SizeT;
275 typedef regex_constants::syntax_option_type _FlagT;
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));
304 _M_accepting_states.insert(this->size()-1);
305 return this->size()-1;
309 _M_insert_alt(_StateIdT __next, _StateIdT __alt)
311 this->push_back(_StateT(__next, __alt));
312 return this->size()-1;
316 _M_insert_matcher(_Matcher __m)
318 this->push_back(_StateT(__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)
360 _StateSeq(
const _StateSeq& __e1,
const _StateSeq& __e2)
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)
367 _StateSeq(
const _StateSeq& __e, _StateIdT __id)
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)
374 _StateSeq(
const _StateSeq& __rhs)
375 : _M_nfa(__rhs._M_nfa), _M_start(__rhs._M_start),
376 _M_end1(__rhs._M_end1), _M_end2(__rhs._M_end2)
380 _StateSeq& operator=(
const _StateSeq& __rhs);
388 _M_push_back(_StateIdT __id);
392 _M_append(_StateIdT __id);
395 _M_append(_StateSeq& __rhs);
410 _GLIBCXX_END_NAMESPACE_VERSION
namespace std _GLIBCXX_VISIBILITY(default)
Definition: auto_ptr.h:36