@@ -1670,6 +1670,8 @@ private:
1670
1670
_Tgt_state_t<_It> _Res;
1671
1671
vector<_Loop_vals_t> _Loop_vals;
1672
1672
1673
+ bool _Do_assert(_Node_assert*);
1674
+ bool _Do_neg_assert(_Node_assert*);
1673
1675
bool _Do_if(_Node_if*);
1674
1676
bool _Do_rep0(_Node_rep*, bool);
1675
1677
bool _Do_rep(_Node_rep*, bool, int);
@@ -3142,6 +3144,28 @@ void _Builder<_FwdIt, _Elem, _RxTraits>::_Tidy() noexcept { // free memory
3142
3144
_Root = nullptr;
3143
3145
}
3144
3146
3147
+ template <class _BidIt, class _Elem, class _RxTraits, class _It>
3148
+ bool _Matcher<_BidIt, _Elem, _RxTraits, _It>::_Do_assert(_Node_assert* _Node) { // apply assert node
3149
+ _It _Ch = _Tgt_state._Cur;
3150
+ if (_Match_pat(_Node->_Child)) {
3151
+ _Tgt_state._Cur = _Ch;
3152
+ return true;
3153
+ } else {
3154
+ return false;
3155
+ }
3156
+ }
3157
+
3158
+ template <class _BidIt, class _Elem, class _RxTraits, class _It>
3159
+ bool _Matcher<_BidIt, _Elem, _RxTraits, _It>::_Do_neg_assert(_Node_assert* _Node) { // apply negative assert node
3160
+ _Bt_state_t<_It> _St = _Tgt_state;
3161
+ if (!_Match_pat(_Node->_Child)) {
3162
+ _Tgt_state = _St;
3163
+ return true;
3164
+ } else {
3165
+ return false;
3166
+ }
3167
+ }
3168
+
3145
3169
template <class _BidIt, class _Elem, class _RxTraits, class _It>
3146
3170
bool _Matcher<_BidIt, _Elem, _RxTraits, _It>::_Do_if(_Node_if* _Node) { // apply if node
3147
3171
_Tgt_state_t<_It> _St = _Tgt_state;
@@ -3597,20 +3621,15 @@ bool _Matcher<_BidIt, _Elem, _RxTraits, _It>::_Match_pat(_Node_base* _Nx) { // c
3597
3621
case _N_end_group:
3598
3622
break;
3599
3623
3600
- case _N_neg_assert:
3601
3624
case _N_assert:
3602
3625
{ // check assert
3603
- _It _Ch = _Tgt_state._Cur;
3604
- bool _Neg = _Nx->_Kind == _N_neg_assert;
3605
- _Bt_state_t<_It> _St = _Tgt_state;
3606
- if (_Match_pat(static_cast<_Node_assert*>(_Nx)->_Child) == _Neg) {
3607
- // restore initial state and indicate failure
3608
- _Tgt_state = _St;
3609
- _Failed = true;
3610
- } else {
3611
- _Tgt_state._Cur = _Ch;
3612
- }
3626
+ _Failed = !_Do_assert(static_cast<_Node_assert*>(_Nx));
3627
+ break;
3628
+ }
3613
3629
3630
+ case _N_neg_assert:
3631
+ { // check negative assert
3632
+ _Failed = !_Do_neg_assert(static_cast<_Node_assert*>(_Nx));
3614
3633
break;
3615
3634
}
3616
3635
0 commit comments