STLdoc
STLdocumentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
_Parser< _FwdIt, _Elem, _RxTraits > Class Template Reference

Public Types

typedef _RxTraits::char_class_type char_class_type
 

Public Member Functions

 _Parser (const _RxTraits &_Tr, _FwdIt _Pfirst, _FwdIt _Plast, regex_constants::syntax_option_type _Fx)
 
_Root_node_Compile ()
 
unsigned int _Mark_count () const
 

Private Member Functions

void _Error (regex_constants::error_type)
 
bool _Is_esc () const
 
void _Trans ()
 
void _Next ()
 
void _Expect (_Meta_type, regex_constants::error_type)
 
int _Do_digits (int _Base, int _Count)
 
bool _DecimalDigits ()
 
void _HexDigits (int)
 
bool _OctalDigits ()
 
void _Do_ex_class (_Meta_type)
 
bool _CharacterClassEscape (bool)
 
_Prs_ret _ClassEscape (bool)
 
_Prs_ret _ClassAtom ()
 
void _ClassRanges ()
 
void _CharacterClass ()
 
bool _IdentityEscape ()
 
bool _Do_ffn (_Elem)
 
bool _Do_ffnx (_Elem)
 
bool _CharacterEscape ()
 
void _AtomEscape ()
 
void _Do_capture_group ()
 
void _Do_noncapture_group ()
 
void _Do_assert_group (bool)
 
bool _Wrapped_disjunction ()
 
void _Quantifier ()
 
bool _Alternative ()
 
void _Disjunction ()
 

Private Attributes

_FwdIt _Pat
 
_FwdIt _Begin
 
_FwdIt _End
 
int _Grp_idx
 
int _Disj_count
 
vector< bool_Finished_grps
 
_Builder< _FwdIt, _Elem, _RxTraits > _Nfa
 
const _RxTraits & _Traits
 
regex_constants::syntax_option_type _Flags
 
int _Val
 
_Elem _Char
 
_Meta_type _Mchar
 
unsigned int _L_flags
 

Member Typedef Documentation

template<class _FwdIt , class _Elem , class _RxTraits >
typedef _RxTraits::char_class_type _Parser< _FwdIt, _Elem, _RxTraits >::char_class_type

Constructor & Destructor Documentation

template<class _FwdIt , class _Elem , class _RxTraits >
_Parser< _FwdIt, _Elem, _RxTraits >::_Parser ( const _RxTraits &  _Tr,
_FwdIt  _Pfirst,
_FwdIt  _Plast,
regex_constants::syntax_option_type  _Fx 
)
inline
5550  _Grp_idx(0), _Disj_count(0), _Finished_grps(0),
5551  _Nfa(_Tr, _Fx), _Traits(_Tr), _Flags(_Fx)
5552  { // construct
5553  using namespace regex_constants;
5554  _L_flags = (_Flags & _Gmask) == ECMAScript
5555  || (_Flags & _Gmask) == 0 ? _ECMA_flags
5556  : (_Flags & _Gmask) == basic ? _Basic_flags
5557  : (_Flags & _Gmask) == extended ? _Extended_flags
5558  : (_Flags & _Gmask) == awk ? _Awk_flags
5559  : (_Flags & _Gmask) == grep ? _Grep_flags
5560  : (_Flags & _Gmask) == egrep ? _Egrep_flags
5561  : 0;
5562  if (_L_flags & _L_mtch_long)
5563  _Nfa._Setlong();
5564  _Trans();
5565  }
_Builder< _FwdIt, _Elem, _RxTraits > _Nfa
Definition: regex:2162
Definition: regex:132
static const unsigned int _Grep_flags
Definition: regex:4764
_FwdIt _Begin
Definition: regex:2157
_RanIt _Plast
Definition: algorithm:2577
Definition: regex:140
Definition: regex:137
static const unsigned int _Extended_flags
Definition: regex:4767
regex_constants::syntax_option_type _Flags
Definition: regex:2164
_FwdIt _End
Definition: regex:2158
static const unsigned int _ECMA_flags
Definition: regex:4753
_RanIt _Pfirst
Definition: algorithm:2576
Definition: regex:142
const _RxTraits & _Traits
Definition: regex:2163
Definition: regex:136
Definition: regex:139
Definition: regex:2203
void _Trans()
Definition: regex:4811
Definition: regex:138
vector< bool > _Finished_grps
Definition: regex:2161
static const unsigned int _Awk_flags
Definition: regex:4771
_FwdIt _Pat
Definition: regex:2156
Definition: regex:141
int _Grp_idx
Definition: regex:2159
unsigned int _L_flags
Definition: regex:2168
int _Disj_count
Definition: regex:2160
static const unsigned int _Basic_flags
Definition: regex:4760
static const unsigned int _Egrep_flags
Definition: regex:4774

Member Function Documentation

template<class _FwdIt , class _Elem , class _RxTraits >
bool _Parser< _FwdIt, _Elem, _RxTraits >::_Alternative ( )
inlineprivate
5413  { // check for valid alternative
5414  bool _Found = false;
5415  for (; ; )
5416  { // concatenate valid elements
5417  bool _Quant = true;
5418  if (_Mchar == _Meta_eos || _Mchar == _Meta_bar
5419  || (_Mchar == _Meta_rpar && _Disj_count != 0))
5420  return (_Found);
5421  else if (_Mchar == _Meta_rpar && !(_L_flags & _L_paren_bal))
5423  else if (_Mchar == _Meta_dot)
5424  { // add dot node
5425  _Nfa._Add_dot();
5426  _Next();
5427  }
5428  else if (_Mchar == _Meta_esc)
5429  { // check for valid escape sequence
5430  _Next();
5431  if ((_L_flags & _L_asrt_wrd) && _Char == _Esc_word)
5432  { // add word assert
5433  _Nfa._Add_wbound();
5434  _Next();
5435  _Quant = false;
5436  }
5437  else if ((_L_flags & _L_asrt_wrd) && _Char == _Esc_not_word)
5438  { // add not-word assert
5439  _Nfa._Add_wbound();
5440  _Nfa._Negate();
5441  _Next();
5442  _Quant = false;
5443  }
5444  else
5445  _AtomEscape();
5446  }
5447  else if (_Mchar == _Meta_lsq)
5448  { // add bracket expression
5449  _Next();
5450  _CharacterClass();
5452  }
5453  else if (_Mchar == _Meta_lpar)
5454  { // check for valid group
5455  _Next();
5456  _Quant = _Wrapped_disjunction();
5458  }
5459  else if (_Mchar == _Meta_caret)
5460  { // add bol node
5461  _Nfa._Add_bol();
5462  _Next();
5463  _Quant = false;
5464  }
5465  else if (_Mchar == _Meta_dlr)
5466  { // add eol node
5467  _Nfa._Add_eol();
5468  _Next();
5469  _Quant = false;
5470  }
5471  else if (_Mchar == _Meta_star
5472  || _Mchar == _Meta_plus
5473  || _Mchar == _Meta_query
5474  || _Mchar == _Meta_lbr)
5476  else if (_Mchar == _Meta_rbr && !(_L_flags & _L_paren_bal))
5478  else if (_Mchar == _Meta_rsq && !(_L_flags & _L_paren_bal))
5480  else
5481  { // add character
5482  _Nfa._Add_char(_Char);
5483  _Next();
5484  }
5485  if (_Quant)
5486  _Quantifier();
5487  _Found = true;
5488  }
5489  }
_Builder< _FwdIt, _Elem, _RxTraits > _Nfa
Definition: regex:2162
_Meta_type _Mchar
Definition: regex:2167
Definition: regex:74
void _AtomEscape()
Definition: regex:5339
Definition: regex:60
Definition: regex:64
Definition: regex:82
_Elem _Char
Definition: regex:2166
Definition: regex:2180
Definition: regex:65
Definition: regex:58
Definition: regex:55
Definition: regex:69
Definition: regex:181
Definition: regex:179
void _Next()
Definition: regex:4885
Definition: regex:81
Definition: regex:68
void _Quantifier()
Definition: regex:5365
Definition: regex:180
void _Expect(_Meta_type, regex_constants::error_type)
Definition: regex:4899
Definition: regex:56
Definition: regex:61
void _CharacterClass()
Definition: regex:5133
Definition: regex:62
bool _Wrapped_disjunction()
Definition: regex:5186
Definition: regex:57
Definition: regex:66
unsigned int _L_flags
Definition: regex:2168
Definition: regex:2201
Definition: regex:63
int _Disj_count
Definition: regex:2160
Definition: regex:59
void _Error(regex_constants::error_type)
Definition: regex:4780
template<class _FwdIt , class _Elem , class _RxTraits >
void _Parser< _FwdIt, _Elem, _RxTraits >::_AtomEscape ( )
inlineprivate
5340  { // check for valid atom escape
5341  if ((_L_flags & _L_bckr) && _DecimalDigits())
5342  { // check for valid back reference
5343  if (_Val == 0)
5344  { // handle \0
5345  if (!(_L_flags & _L_bzr_chr))
5347  else
5348  _Nfa._Add_char((_Elem)_Val);
5349  }
5350  else if (((_L_flags & _L_lim_bckr) && _BRE_MAX_GRP < _Val)
5351  || _Grp_idx < _Val || !_Finished_grps[_Val])
5353  else
5354  _Nfa._Add_backreference(_Val);
5355  }
5356  else if (_CharacterEscape())
5357  _Nfa._Add_char((_Elem)_Val);
5358  else if (!(_L_flags & _L_esc_wsd) || !_CharacterClassEscape(true))
5360  }
bool _DecimalDigits()
Definition: regex:4928
_Builder< _FwdIt, _Elem, _RxTraits > _Nfa
Definition: regex:2162
Definition: regex:2193
Definition: regex:178
Definition: regex:177
int _Val
Definition: regex:2165
bool _CharacterClassEscape(bool)
Definition: regex:5001
Definition: regex:2181
bool _CharacterEscape()
Definition: regex:5298
Definition: regex:2182
vector< bool > _Finished_grps
Definition: regex:2161
int _Grp_idx
Definition: regex:2159
const int _BRE_MAX_GRP
Definition: regex:1457
Definition: regex:2190
unsigned int _L_flags
Definition: regex:2168
void _Error(regex_constants::error_type)
Definition: regex:4780
template<class _FwdIt , class _Elem , class _RxTraits >
void _Parser< _FwdIt, _Elem, _RxTraits >::_CharacterClass ( )
inlineprivate
5134  { // add bracket expression
5135  _Nfa._Add_class();
5136  if (_Mchar == _Meta_caret)
5137  { // negate bracket expression
5138  _Nfa._Negate();
5139  _Next();
5140  }
5141  if ((_L_flags & _L_brk_rstr) && _Mchar == _Meta_rsq)
5142  { // insert initial ] when not special
5143  _Nfa._Add_char_to_class(_Meta_rsq);
5144  _Next();
5145  }
5146  _ClassRanges();
5147  }
Definition: regex:2202
_Builder< _FwdIt, _Elem, _RxTraits > _Nfa
Definition: regex:2162
_Meta_type _Mchar
Definition: regex:2167
Definition: regex:64
Definition: regex:58
void _Next()
Definition: regex:4885
void _ClassRanges()
Definition: regex:5092
unsigned int _L_flags
Definition: regex:2168
template<class _FwdIt , class _Elem , class _RxTraits >
bool _Parser< _FwdIt, _Elem, _RxTraits >::_CharacterClassEscape ( bool  _Addit)
inlineprivate
5002  { // check for character class escape
5003  typename _RxTraits::char_class_type _Cls;
5004  _FwdIt _Ch0 = _Pat;
5005  if (_Ch0 == _End
5006  || (_Cls = _Traits.lookup_classname(_Pat, ++_Ch0,
5007  (_Flags & regex_constants::icase) != 0)) == 0)
5008  return (false);
5009 
5010  if (_Addit)
5011  _Nfa._Add_class();
5012  _Nfa._Add_named_class(_Cls);
5013  if (_Traits.isctype(_Char, _RxTraits::_Ch_upper))
5014  _Nfa._Negate();
5015  _Next();
5016  return (true);
5017  }
_Builder< _FwdIt, _Elem, _RxTraits > _Nfa
Definition: regex:2162
_Elem _Char
Definition: regex:2166
regex_constants::syntax_option_type _Flags
Definition: regex:2164
_FwdIt _End
Definition: regex:2158
const _RxTraits & _Traits
Definition: regex:2163
void _Next()
Definition: regex:4885
Definition: regex:144
_FwdIt _Pat
Definition: regex:2156
template<class _FwdIt , class _Elem , class _RxTraits >
bool _Parser< _FwdIt, _Elem, _RxTraits >::_CharacterEscape ( )
inlineprivate
5299  { // check for valid character escape
5300  if ((_L_flags & _L_esc_ffn && _Do_ffn(_Char))
5301  || (_L_flags & _L_esc_ffnx && _Do_ffnx(_Char)))
5302  _Next();
5303  else if (_Char == _Esc_ctrl && (_L_flags & _L_esc_ctrl))
5304  { // handle control escape sequence
5305  _Next();
5306  if (!_Traits.isctype(_Char, _RxTraits::_Ch_alpha))
5308  _Val = (char)(_Char % 32);
5309  _Next();
5310  }
5311  else if (_Char == _Esc_hex && (_L_flags & _L_esc_hex))
5312  { // handle hexadecimal escape sequence
5313  _Next();
5314  _HexDigits(2);
5315  }
5316  else if (_Char == _Esc_uni && (_L_flags & _L_esc_uni))
5317  { // handle unicode escape sequence
5318  _Next();
5319  _HexDigits(4);
5320  }
5321  else if ((_L_flags & _L_esc_oct) && _OctalDigits())
5322  { // handle octal escape sequence
5323  if (_Val == 0)
5325  }
5326  else
5327  return (_IdentityEscape());
5328 
5329  typedef typename make_unsigned<_Elem>::type _Uelem;
5330  if ((numeric_limits<_Uelem>::max)() < (unsigned int)_Val)
5332  _Val = (_Elem)_Val;
5333  return (true);
5334  }
Definition: regex:2184
Definition: regex:2186
_Elem _Char
Definition: regex:2166
Definition: regex:90
Definition: regex:177
Definition: regex:2191
Definition: regex:2189
int _Val
Definition: regex:2165
bool _Do_ffn(_Elem)
Definition: regex:5264
void _HexDigits(int)
Definition: regex:4936
const _RxTraits & _Traits
Definition: regex:2163
bool _OctalDigits()
Definition: regex:4945
Definition: regex:2188
Definition: regex:91
void _Next()
Definition: regex:4885
Definition: regex:2185
bool _Do_ffnx(_Elem)
Definition: regex:5286
Definition: regex:92
bool _IdentityEscape()
Definition: regex:5224
unsigned int _L_flags
Definition: regex:2168
Definition: limits:79
void _Error(regex_constants::error_type)
Definition: regex:4780
template<class _FwdIt , class _Elem , class _RxTraits >
_Prs_ret _Parser< _FwdIt, _Elem, _RxTraits >::_ClassAtom ( )
inlineprivate
5046  { // check for class atom
5047  if (_Mchar == _Meta_esc)
5048  { // check for valid escape sequence
5049  _Next();
5050  if (_L_flags & _L_grp_esc)
5051  return (_ClassEscape(false));
5052  else if ((_L_flags & _L_esc_ffn && _Do_ffn(_Char))
5053  || (_L_flags & _L_esc_ffnx && _Do_ffnx(_Char)))
5054  { // advance to next character
5055  _Next();
5056  return (_Prs_chr);
5057  }
5058  _Val = _Meta_esc;
5059  return (_Prs_chr);
5060  }
5061  else if (_Mchar == _Meta_lsq)
5062  { // check for valid delimited expression
5063  _Next();
5064  if (_Mchar == _Meta_colon
5065  || _Mchar == _Meta_equal
5066  || _Mchar == _Meta_dot)
5067  { // handle delimited expression
5068  _Meta_type _St = _Mchar;
5069  _Next();
5070  _Do_ex_class(_St);
5071  return (_Prs_set);
5072  }
5073  else
5074  { // handle ordinary [
5075  _Val = _Meta_lsq;
5076  return (_Prs_chr);
5077  }
5078  }
5079  else if (_Mchar == _Meta_rsq || _Mchar == _Meta_eos)
5080  return (_Prs_none);
5081  else
5082  { // handle ordinary character
5083  _Val = _Char;
5084  _Next();
5085  return (_Prs_chr);
5086  }
5087  }
_Meta_type _Mchar
Definition: regex:2167
Definition: regex:74
Definition: regex:64
Definition: regex:72
void _Do_ex_class(_Meta_type)
Definition: regex:4953
_Elem _Char
Definition: regex:2166
Definition: regex:2101
Definition: regex:2189
int _Val
Definition: regex:2165
Definition: regex:2194
bool _Do_ffn(_Elem)
Definition: regex:5264
_Prs_ret _ClassEscape(bool)
Definition: regex:5022
Definition: regex:2188
Definition: regex:2100
void _Next()
Definition: regex:4885
Definition: regex:71
bool _Do_ffnx(_Elem)
Definition: regex:5286
Definition: regex:2102
Definition: regex:66
unsigned int _L_flags
Definition: regex:2168
Definition: regex:63
Definition: regex:59
_Meta_type
Definition: regex:53
template<class _FwdIt , class _Elem , class _RxTraits >
_Prs_ret _Parser< _FwdIt, _Elem, _RxTraits >::_ClassEscape ( bool  _Addit)
inlineprivate
5023  { // check for class escape
5024  if ((_L_flags & _L_esc_bsl)
5025  && _Char == _Esc_bsl)
5026  { // handle escape backslash if allowed
5027  _Val = _Esc_bsl;
5028  _Next();
5029  return (_Prs_chr);
5030  }
5031  else if ((_L_flags & _L_esc_wsd) && _CharacterClassEscape(_Addit))
5032  return (_Prs_set);
5033  else if (_DecimalDigits())
5034  { // check for invalid value
5035  if (_Val != 0)
5037  return (_Prs_chr);
5038  }
5039  return (_CharacterEscape() ? _Prs_chr : _Prs_none);
5040  }
bool _DecimalDigits()
Definition: regex:4928
Definition: regex:2187
_Elem _Char
Definition: regex:2166
Definition: regex:177
Definition: regex:2101
int _Val
Definition: regex:2165
bool _CharacterClassEscape(bool)
Definition: regex:5001
Definition: regex:2100
bool _CharacterEscape()
Definition: regex:5298
void _Next()
Definition: regex:4885
Definition: regex:2102
Definition: regex:2190
Definition: regex:80
unsigned int _L_flags
Definition: regex:2168
void _Error(regex_constants::error_type)
Definition: regex:4780
template<class _FwdIt , class _Elem , class _RxTraits >
void _Parser< _FwdIt, _Elem, _RxTraits >::_ClassRanges ( )
inlineprivate
5093  { // check for valid class ranges
5094  _Prs_ret _Ret;
5095 
5096  for (; ; )
5097  { // process characters through end of bracket expression
5098  if ((_Ret = _ClassAtom()) == _Prs_none)
5099  return;
5100  else if (_Ret == _Prs_set)
5101  ;
5102  else if (_Val == 0 && !(_L_flags & _L_bzr_chr))
5104  else if (_Mchar == _Meta_dash)
5105  { // check for valid range
5106  _Next();
5107  _Elem _Chr1 = (_Elem)_Val;
5108  if ((_Ret = _ClassAtom()) == _Prs_none)
5109  { // treat - as ordinary character
5110  _Nfa._Add_char_to_class((_Elem)_Val);
5111  _Nfa._Add_char_to_class(_Meta_dash);
5112  return;
5113  }
5114  else if (_Ret == _Prs_set)
5115  _Error(regex_constants::error_range); // set follows dash
5116  else if (_Flags & regex_constants::collate)
5117  { // translate ends of range
5118  _Val = _Traits.translate((_Elem)_Val);
5119  _Chr1 = _Traits.translate(_Chr1);
5120  }
5121  if (_Val < _Chr1)
5123  _Nfa._Add_range(_Chr1, (_Elem)_Val);
5124  }
5125  else
5126  _Nfa._Add_char_to_class((_Elem)_Val);
5127  }
5128  }
_Builder< _FwdIt, _Elem, _RxTraits > _Nfa
Definition: regex:2162
_Meta_type _Mchar
Definition: regex:2167
Definition: regex:2193
Definition: regex:177
_Prs_ret
Definition: regex:2098
regex_constants::syntax_option_type _Flags
Definition: regex:2164
int _Val
Definition: regex:2165
const _RxTraits & _Traits
Definition: regex:2163
Definition: regex:183
Definition: regex:2100
Definition: regex:67
_Prs_ret _ClassAtom()
Definition: regex:5045
void _Next()
Definition: regex:4885
Definition: regex:147
Definition: regex:2102
unsigned int _L_flags
Definition: regex:2168
void _Error(regex_constants::error_type)
Definition: regex:4780
template<class _FwdIt , class _Elem , class _RxTraits >
_Root_node * _Parser< _FwdIt, _Elem, _RxTraits >::_Compile ( )
inline
5524  { // compile regular expression
5525  _Root_node *_Res = 0;
5526  _TRY_BEGIN
5527  _Node_base *_Pos1 = _Nfa._Begin_capture_group(0);
5528  _Disjunction();
5529  if (_Pat != _End)
5531  _Nfa._End_group(_Pos1);
5532  _Res = _Nfa._End_pattern();
5533  _Res->_Fl = _Flags;
5534  _Res->_Marks = _Mark_count();
5535  _CATCH_ALL
5536  _Nfa._Discard_pattern();
5537  _RERAISE;
5538  _CATCH_END
5539  return (_Res);
5540  }
unsigned int _Marks
Definition: regex:1669
_Builder< _FwdIt, _Elem, _RxTraits > _Nfa
Definition: regex:2162
#define _TRY_BEGIN
Definition: xstddef:60
#define _CATCH_END
Definition: xstddef:63
regex_constants::syntax_option_type _Flags
Definition: regex:2164
_FwdIt _End
Definition: regex:2158
regex_constants::syntax_option_type _Fl
Definition: regex:1667
#define _CATCH_ALL
Definition: xstddef:62
Definition: regex:189
_FwdIt _Pat
Definition: regex:2156
void _Disjunction()
Definition: regex:5494
#define _RERAISE
Definition: xstddef:74
unsigned int _Mark_count() const
Definition: regex:2118
Definition: regex:1658
Definition: regex:1626
void _Error(regex_constants::error_type)
Definition: regex:4780
template<class _FwdIt , class _Elem , class _RxTraits >
bool _Parser< _FwdIt, _Elem, _RxTraits >::_DecimalDigits ( )
inlineprivate
4929  { // check for decimal value
4930  return (_Do_digits(10, INT_MAX) != INT_MAX);
4931  }
int _Do_digits(int _Base, int _Count)
Definition: regex:4910
#define INT_MAX
Definition: limits.h:40
template<class _FwdIt , class _Elem , class _RxTraits >
void _Parser< _FwdIt, _Elem, _RxTraits >::_Disjunction ( )
inlineprivate
5495  { // check for valid disjunction
5496  _Node_base *_Pos1 = _Nfa._Getmark();
5497  if (_Alternative())
5498  ;
5499  else if (_Mchar != _Meta_bar)
5500  return; // zero-length alternative not followed by '|'
5501  else
5502  { // zero-length leading alternative
5503  _Node_base *_Pos3 = _Nfa._Begin_group();
5504  _Nfa._End_group(_Pos3);
5505  }
5506 
5507  _Node_base *_Pos2 = _Nfa._Begin_if(_Pos1);
5508  while (_Mchar == _Meta_bar)
5509  { // append terms as long as we keep finding | characters
5510  _Next();
5511  if (!_Alternative())
5512  { // zero-length trailing alternative
5513  _Node_base *_Pos3 = _Nfa._Begin_group();
5514  _Nfa._End_group(_Pos3);
5515  }
5516  _Nfa._Else_if(_Pos1, _Pos2);
5517  }
5518  }
_Builder< _FwdIt, _Elem, _RxTraits > _Nfa
Definition: regex:2162
_Meta_type _Mchar
Definition: regex:2167
Definition: regex:65
void _Next()
Definition: regex:4885
bool _Alternative()
Definition: regex:5412
Definition: regex:1626
template<class _FwdIt , class _Elem , class _RxTraits >
void _Parser< _FwdIt, _Elem, _RxTraits >::_Do_assert_group ( bool  _Neg)
inlineprivate
5177  { // add assert group
5178  _Node_base *_Pos1 = _Nfa._Begin_assert_group(_Neg);
5179  _Disjunction();
5180  _Nfa._End_assert_group(_Pos1);
5181  }
_Builder< _FwdIt, _Elem, _RxTraits > _Nfa
Definition: regex:2162
void _Disjunction()
Definition: regex:5494
Definition: regex:1626
template<class _FwdIt , class _Elem , class _RxTraits >
void _Parser< _FwdIt, _Elem, _RxTraits >::_Do_capture_group ( )
inlineprivate
5153  { // add capture group
5154 // if (_MAX_GRP <= ++_Grp_idx)
5155 // _Error(regex_constants::error_complexity);
5156  _Node_base *_Pos1 = _Nfa._Begin_capture_group(++_Grp_idx);
5157  _Disjunction();
5158  _Nfa._End_group(_Pos1);
5160  _Finished_grps[((_Node_capture *)_Pos1)->_Idx] = true;
5161  }
_Builder< _FwdIt, _Elem, _RxTraits > _Nfa
Definition: regex:2162
void resize(size_type _Newsize)
Definition: vector:1099
Definition: regex:1705
vector< bool > _Finished_grps
Definition: regex:2161
void _Disjunction()
Definition: regex:5494
int _Grp_idx
Definition: regex:2159
Definition: regex:1626
template<class _FwdIt , class _Elem , class _RxTraits >
int _Parser< _FwdIt, _Elem, _RxTraits >::_Do_digits ( int  _Base,
int  _Count 
)
inlineprivate
4912  { // translate digits to numeric value
4913  int _Chv;
4914  _Val = 0;
4915  while (_Count != 0 && (_Chv = _Traits.value(_Char, _Base)) != -1)
4916  { // append next digit
4917  --_Count;
4918  _Val *= _Base;
4919  _Val += _Chv;
4920  _Next();
4921  }
4922  return (_Count);
4923  }
_Elem _Char
Definition: regex:2166
int _Val
Definition: regex:2165
const _RxTraits & _Traits
Definition: regex:2163
void _Next()
Definition: regex:4885
_Diff _Count
Definition: algorithm:1941
template<class _FwdIt , class _Elem , class _RxTraits >
void _Parser< _FwdIt, _Elem, _RxTraits >::_Do_ex_class ( _Meta_type  _End)
inlineprivate
4954  { // handle delimited expressions within bracket expression
4955  regex_constants::error_type _Errtype =
4960  _FwdIt _Beg = _Pat;
4961  _REGEX_DIFFT(_FwdIt) _Diff = 0;
4962 
4964  && _Mchar != _Meta_dot && _Mchar != _Meta_eos)
4965  { // advance to end delimiter
4966  _Next();
4967  ++_Diff;
4968  }
4969  if (_Mchar != _End)
4970  _Error(_Errtype);
4971  else if (_End == _Meta_colon)
4972  { // handle named character class
4973  typename _RxTraits::char_class_type _Cls =
4974  _Traits.lookup_classname(_Beg, _Pat,
4975  (_Flags & regex_constants::icase) != 0);
4976  if (!_Cls)
4978  _Nfa._Add_named_class(_Cls);
4979  }
4980  else if (_End == _Meta_equal)
4981  { // process =
4982  if (_Beg == _Pat)
4984  else
4985  _Nfa._Add_equiv(_Beg, _Pat, _Diff);
4986  }
4987  else if (_End == _Meta_dot)
4988  { // process .
4989  if (_Beg == _Pat)
4991  else
4992  _Nfa._Add_coll(_Beg, _Pat, _Diff);
4993  }
4994  _Next();
4995  _Expect(_Meta_rsq, _Errtype);
4996  }
_Builder< _FwdIt, _Elem, _RxTraits > _Nfa
Definition: regex:2162
_Meta_type _Mchar
Definition: regex:2167
Definition: regex:74
Definition: regex:64
Definition: regex:72
regex_constants::syntax_option_type _Flags
Definition: regex:2164
_FwdIt _End
Definition: regex:2158
while(_First< _Pfirst &&!_STLCLRDB_LT(*(_Pfirst-1),*_Pfirst)&&!(*_Pfirst< *(_Pfirst-1)))--_Pfirst
const _RxTraits & _Traits
Definition: regex:2163
Definition: regex:176
Definition: regex:175
void _Next()
Definition: regex:4885
Definition: regex:144
Definition: regex:71
void _Expect(_Meta_type, regex_constants::error_type)
Definition: regex:4899
Definition: regex:189
_FwdIt _Pat
Definition: regex:2156
Definition: regex:59
#define _REGEX_DIFFT(iter)
Definition: regex:47
void _Error(regex_constants::error_type)
Definition: regex:4780
error_type
Definition: regex:173
template<class _FwdIt , class _Elem , class _RxTraits >
bool _Parser< _FwdIt, _Elem, _RxTraits >::_Do_ffn ( _Elem  _Ch)
inlineprivate
5265  { // check for limited file format escape character
5266  if (_Ch == _Esc_ctrl_b)
5267  _Val = '\b';
5268  else if (_Ch == _Esc_ctrl_f)
5269  _Val = '\f';
5270  else if (_Ch == _Esc_ctrl_n)
5271  _Val = '\n';
5272  else if (_Ch == _Esc_ctrl_r)
5273  _Val = '\r';
5274  else if (_Ch == _Esc_ctrl_t)
5275  _Val = '\t';
5276  else if (_Ch == _Esc_ctrl_v)
5277  _Val = '\v';
5278  else
5279  return (false);
5280  return (true);
5281  }
Definition: regex:87
Definition: regex:86
int _Val
Definition: regex:2165
Definition: regex:84
_In_ size_t _In_ unsigned int _Ch
Definition: mbstring.h:161
Definition: regex:88
Definition: regex:89
Definition: regex:85
template<class _FwdIt , class _Elem , class _RxTraits >
bool _Parser< _FwdIt, _Elem, _RxTraits >::_Do_ffnx ( _Elem  _Ch)
inlineprivate
5287  { // check for the remaining file format escape character
5288  if (_Ch == _Esc_ctrl_a)
5289  _Val = '\a';
5290  else
5291  return (false);
5292  return (true);
5293  }
int _Val
Definition: regex:2165
Definition: regex:83
_In_ size_t _In_ unsigned int _Ch
Definition: mbstring.h:161
template<class _FwdIt , class _Elem , class _RxTraits >
void _Parser< _FwdIt, _Elem, _RxTraits >::_Do_noncapture_group ( )
inlineprivate
5167  { // add non-capture group
5168  _Node_base *_Pos1 = _Nfa._Begin_group();
5169  _Disjunction();
5170  _Nfa._End_group(_Pos1);
5171  }
_Builder< _FwdIt, _Elem, _RxTraits > _Nfa
Definition: regex:2162
void _Disjunction()
Definition: regex:5494
Definition: regex:1626
template<class _FwdIt , class _Elem , class _RxTraits >
void _Parser< _FwdIt, _Elem, _RxTraits >::_Error ( regex_constants::error_type  _Code)
inlineprivate
4782  { // handle error
4783  _Xregex_error(_Code);
4784  }
template<class _FwdIt , class _Elem , class _RxTraits >
void _Parser< _FwdIt, _Elem, _RxTraits >::_Expect ( _Meta_type  _St,
regex_constants::error_type  _Code 
)
inlineprivate
4901  { // check whether current meta-character is _St
4902  if (_Mchar != _St)
4903  _Error(_Code);
4904  _Next();
4905  }
_Meta_type _Mchar
Definition: regex:2167
void _Next()
Definition: regex:4885
void _Error(regex_constants::error_type)
Definition: regex:4780
template<class _FwdIt , class _Elem , class _RxTraits >
void _Parser< _FwdIt, _Elem, _RxTraits >::_HexDigits ( int  _Count)
inlineprivate
4937  { // check for _Count hex digits
4938  if (_Do_digits(16, _Count) != 0)
4940  }
int _Do_digits(int _Base, int _Count)
Definition: regex:4910
Definition: regex:177
_Diff _Count
Definition: algorithm:1941
void _Error(regex_constants::error_type)
Definition: regex:4780
template<class _FwdIt , class _Elem , class _RxTraits >
bool _Parser< _FwdIt, _Elem, _RxTraits >::_IdentityEscape ( )
inlineprivate
5225  { // check for valid identity escape
5226  if ((_L_flags & _L_ident_ECMA) &&
5227  // ECMAScript identity escape characters
5228  !_Traits.isctype(_Char, _RxTraits::_Ch_alnum)
5229  && _Char != '_')
5230  ;
5231  else if (!(_L_flags & _L_ident_ECMA) &&
5232  // BRE, ERE, awk identity escape characters
5233  (_Char == _Meta_dot
5234  || _Char == _Meta_lsq
5235  || _Char == _Meta_esc
5236  || _Char == _Meta_star
5237  || _Char == _Meta_bar
5238  || _Char == _Meta_caret
5239  || _Char == _Meta_dlr))
5240  ;
5241  else if ((_L_flags & _L_ident_ERE) &&
5242  // additional ERE identity escape characters
5243  (_Char == _Meta_lpar
5244  || _Char == _Meta_rpar
5245  || _Char == _Meta_plus
5246  || _Char == _Meta_query
5247  || _Char == _Meta_lbr
5248  || _Char == _Meta_rbr))
5249  ;
5250  else if ((_L_flags & _L_ident_awk) &&
5251  // additional awk identity escape characters
5252  (_Char == '"' || _Char == '/'))
5253  ;
5254  else
5255  return (false);
5256  _Val = _Char;
5257  _Next();
5258  return (true);
5259  }
Definition: regex:60
_Elem _Char
Definition: regex:2166
Definition: regex:2195
int _Val
Definition: regex:2165
Definition: regex:65
Definition: regex:58
const _RxTraits & _Traits
Definition: regex:2163
Definition: regex:2196
Definition: regex:55
Definition: regex:69
void _Next()
Definition: regex:4885
Definition: regex:68
Definition: regex:56
Definition: regex:2197
Definition: regex:61
Definition: regex:62
Definition: regex:57
Definition: regex:66
unsigned int _L_flags
Definition: regex:2168
Definition: regex:63
Definition: regex:59
template<class _FwdIt , class _Elem , class _RxTraits >
bool _Parser< _FwdIt, _Elem, _RxTraits >::_Is_esc ( ) const
inlineprivate
4790  { // assumes _Pat != _End
4791  _FwdIt _Ch0 = _Pat;
4792  return (++_Ch0 != _End
4793  && ((!(_L_flags & _L_nex_grp)
4794  && (*_Ch0 == _Meta_lpar || *_Ch0 == _Meta_rpar))
4795  || (!(_L_flags & _L_nex_rep)
4796  && (*_Ch0 == _Meta_lbr || *_Ch0 == _Meta_rbr))));
4797  }
Definition: regex:2177
_FwdIt _End
Definition: regex:2158
Definition: regex:55
Definition: regex:69
Definition: regex:68
Definition: regex:56
_FwdIt _Pat
Definition: regex:2156
Definition: regex:2176
unsigned int _L_flags
Definition: regex:2168
template<class _FwdIt , class _Elem , class _RxTraits >
unsigned int _Parser< _FwdIt, _Elem, _RxTraits >::_Mark_count ( ) const
inline
2119  { // return number of capture groups
2120  return (_Grp_idx + 1);
2121  }
int _Grp_idx
Definition: regex:2159
template<class _FwdIt , class _Elem , class _RxTraits >
void _Parser< _FwdIt, _Elem, _RxTraits >::_Next ( )
inlineprivate
4886  { // advance to next input character
4887  if (_Pat != _End)
4888  { // advance
4889  if (*_Pat == _Meta_esc && _Is_esc())
4890  ++_Pat;
4891  ++_Pat;
4892  }
4893  _Trans();
4894  }
_FwdIt _End
Definition: regex:2158
bool _Is_esc() const
Definition: regex:4789
void _Trans()
Definition: regex:4811
_FwdIt _Pat
Definition: regex:2156
Definition: regex:66
template<class _FwdIt , class _Elem , class _RxTraits >
bool _Parser< _FwdIt, _Elem, _RxTraits >::_OctalDigits ( )
inlineprivate
4946  { // check for up to 3 octal digits
4947  return (_Do_digits(8, 3) != 3);
4948  }
int _Do_digits(int _Base, int _Count)
Definition: regex:4910
template<class _FwdIt , class _Elem , class _RxTraits >
void _Parser< _FwdIt, _Elem, _RxTraits >::_Quantifier ( )
inlineprivate
5366  { // check for quantifier following atom
5367  int _Min = 0;
5368  int _Max = -1;
5369  if (_Mchar == _Meta_star)
5370  ;
5371  else if (_Mchar == _Meta_plus)
5372  _Min = 1;
5373  else if (_Mchar == _Meta_query)
5374  _Max = 1;
5375  else if (_Mchar == _Meta_lbr)
5376  { // check for valid bracketed value
5377  _Next();
5378  if (!_DecimalDigits())
5380  _Min = _Val;
5381  if (_Mchar != _Meta_comma)
5382  _Max = _Min;
5383  else
5384  { // check for decimal constant following comma
5385  _Next();
5386  if (_Mchar == _Meta_rbr)
5387  ;
5388  else if (!_DecimalDigits())
5390  else
5391  _Max = _Val;
5392  }
5393  if (_Mchar != _Meta_rbr || (_Max != -1 && _Max < _Min))
5395  }
5396  else
5397  return;
5398  _Nfa._Mark_final();
5399  _Next();
5400  if ((_L_flags & _L_ngr_rep) && _Mchar == _Meta_query)
5401  { // add non-greedy repeat node
5402  _Next();
5403  _Nfa._Add_rep(_Min, _Max, false);
5404  }
5405  else
5406  _Nfa._Add_rep(_Min, _Max, true);
5407  }
bool _DecimalDigits()
Definition: regex:4928
_Builder< _FwdIt, _Elem, _RxTraits > _Nfa
Definition: regex:2162
_Meta_type _Mchar
Definition: regex:2167
Definition: regex:60
Definition: regex:70
Definition: regex:182
int _Val
Definition: regex:2165
Definition: regex:69
void _Next()
Definition: regex:4885
Definition: regex:68
Definition: regex:61
Definition: regex:62
Definition: regex:2183
unsigned int _L_flags
Definition: regex:2168
void _Error(regex_constants::error_type)
Definition: regex:4780
template<class _FwdIt , class _Elem , class _RxTraits >
void _Parser< _FwdIt, _Elem, _RxTraits >::_Trans ( )
inlineprivate
4812  { // map character to meta-character
4813  if (_Pat == _End)
4814  _Mchar = _Meta_eos, _Char = (_Elem)_Meta_eos;
4815  else
4816  { // map current character
4817  _Char = *_Pat;
4818  _Mchar = _CSTD strchr(_Meta_map, _Char) != 0
4819  ? (_Meta_type)_Char : _Meta_chr;
4820  }
4821  switch (_Char)
4822  { // handle special cases
4823  case _Meta_esc:
4824  if (_Is_esc())
4825  { // replace escape sequence
4826  _FwdIt _Ch0 = _Pat;
4827  _Mchar = _Meta_type(_Char = *++_Ch0);
4828  }
4829  break;
4830 
4831  case _Meta_nl:
4832  if ((_L_flags & _L_alt_nl) && _Disj_count == 0)
4833  _Mchar = _Meta_bar;
4834  break;
4835 
4836  case _Meta_lpar:
4837  case _Meta_rpar:
4838  if (!(_L_flags & _L_nex_grp))
4839  _Mchar = _Meta_chr;
4840  break;
4841 
4842  case _Meta_lbr:
4843  case _Meta_rbr:
4844  if (!(_L_flags & _L_nex_rep))
4845  _Mchar = _Meta_chr;
4846  break;
4847 
4848  case _Meta_star:
4849  if ((_L_flags & _L_star_beg)
4850  && _Nfa._Beg_expr())
4851  _Mchar = _Meta_chr;
4852  break;
4853 
4854  case _Meta_caret:
4855  if ((_L_flags & _L_anch_rstr)
4856  && !_Nfa._Beg_expr())
4857  _Mchar = _Meta_chr;
4858  break;
4859 
4860  case _Meta_dlr:
4861  { // check if $ is special
4862  _FwdIt _Ch0 = _Pat;
4863  if ((_L_flags & _L_anch_rstr)
4864  && ++_Ch0 != _End && *_Ch0 != _Meta_nl)
4865  _Mchar = _Meta_chr;
4866  break;
4867  }
4868 
4869  case _Meta_plus:
4870  case _Meta_query:
4871  if (!(_L_flags & _L_ext_rep))
4872  _Mchar = _Meta_chr;
4873  break;
4874 
4875  case _Meta_bar:
4876  if (!(_L_flags & _L_alt_pipe))
4877  _Mchar = _Meta_chr;
4878  break;
4879  }
4880  }
Definition: regex:2177
_Builder< _FwdIt, _Elem, _RxTraits > _Nfa
Definition: regex:2162
_Meta_type _Mchar
Definition: regex:2167
Definition: regex:74
Definition: regex:2198
Definition: regex:60
Definition: regex:2199
_Elem _Char
Definition: regex:2166
_FwdIt _End
Definition: regex:2158
Definition: regex:65
Definition: regex:58
Definition: regex:55
Definition: regex:69
bool _Is_esc() const
Definition: regex:4789
Definition: regex:78
Definition: regex:2173
Definition: regex:68
Definition: regex:75
_Check_return_ _CRTIMP _CONST_RETURN char *__cdecl strchr(_In_z_ const char *_Str, _In_ int _Val)
Definition: regex:56
Definition: regex:61
Definition: regex:62
_FwdIt _Pat
Definition: regex:2156
#define _CSTD
Definition: yvals.h:559
Definition: regex:57
Definition: regex:2176
Definition: regex:66
unsigned int _L_flags
Definition: regex:2168
static const char _Meta_map[]
Definition: regex:4799
int _Disj_count
Definition: regex:2160
Definition: regex:2175
Definition: regex:2174
_Meta_type
Definition: regex:53
template<class _FwdIt , class _Elem , class _RxTraits >
bool _Parser< _FwdIt, _Elem, _RxTraits >::_Wrapped_disjunction ( )
inlineprivate
5187  { // add disjunction inside group
5188  ++_Disj_count;
5189  if (!(_L_flags & _L_empty_grp) && _Mchar == _Meta_rpar)
5191  else if ((_L_flags & _L_nc_grp) && _Mchar == _Meta_query)
5192  { // check for valid ECMAScript (?x ... ) group
5193  _Next();
5195  _Next();
5196  if (_Ch == _Meta_colon)
5198  else if (_Ch == _Meta_exc)
5199  { // process assert group, negating
5200  _Do_assert_group(true);
5201  --_Disj_count;
5202  return (false);
5203  }
5204  else if (_Ch == _Meta_equal)
5205  { // process assert group
5206  _Do_assert_group(false);
5207  --_Disj_count;
5208  return (false);
5209  }
5210  else
5212  }
5213  else if (_Flags & regex_constants::nosubs)
5215  else
5217  --_Disj_count;
5218  return (true);
5219  }
Definition: regex:145
_Meta_type _Mchar
Definition: regex:2167
void _Do_noncapture_group()
Definition: regex:5166
void _Do_assert_group(bool)
Definition: regex:5176
Definition: regex:73
Definition: regex:72
regex_constants::syntax_option_type _Flags
Definition: regex:2164
void _Do_capture_group()
Definition: regex:5152
Definition: regex:2200
void _Next()
Definition: regex:4885
Definition: regex:71
_In_ size_t _In_ unsigned int _Ch
Definition: mbstring.h:161
Definition: regex:180
Definition: regex:56
Definition: regex:189
Definition: regex:2178
Definition: regex:62
unsigned int _L_flags
Definition: regex:2168
int _Disj_count
Definition: regex:2160
_Meta_type
Definition: regex:53
void _Error(regex_constants::error_type)
Definition: regex:4780

Member Data Documentation

template<class _FwdIt , class _Elem , class _RxTraits >
_FwdIt _Parser< _FwdIt, _Elem, _RxTraits >::_Begin
private
template<class _FwdIt , class _Elem , class _RxTraits >
_Elem _Parser< _FwdIt, _Elem, _RxTraits >::_Char
private
template<class _FwdIt , class _Elem , class _RxTraits >
int _Parser< _FwdIt, _Elem, _RxTraits >::_Disj_count
private
template<class _FwdIt , class _Elem , class _RxTraits >
_FwdIt _Parser< _FwdIt, _Elem, _RxTraits >::_End
private
template<class _FwdIt , class _Elem , class _RxTraits >
vector<bool> _Parser< _FwdIt, _Elem, _RxTraits >::_Finished_grps
private
template<class _FwdIt , class _Elem , class _RxTraits >
regex_constants::syntax_option_type _Parser< _FwdIt, _Elem, _RxTraits >::_Flags
private
template<class _FwdIt , class _Elem , class _RxTraits >
int _Parser< _FwdIt, _Elem, _RxTraits >::_Grp_idx
private
template<class _FwdIt , class _Elem , class _RxTraits >
unsigned int _Parser< _FwdIt, _Elem, _RxTraits >::_L_flags
private
template<class _FwdIt , class _Elem , class _RxTraits >
_Meta_type _Parser< _FwdIt, _Elem, _RxTraits >::_Mchar
private
template<class _FwdIt , class _Elem , class _RxTraits >
_Builder<_FwdIt, _Elem, _RxTraits> _Parser< _FwdIt, _Elem, _RxTraits >::_Nfa
private
template<class _FwdIt , class _Elem , class _RxTraits >
_FwdIt _Parser< _FwdIt, _Elem, _RxTraits >::_Pat
private
template<class _FwdIt , class _Elem , class _RxTraits >
const _RxTraits& _Parser< _FwdIt, _Elem, _RxTraits >::_Traits
private
template<class _FwdIt , class _Elem , class _RxTraits >
int _Parser< _FwdIt, _Elem, _RxTraits >::_Val
private

The documentation for this class was generated from the following file: