@@ -537,18 +537,17 @@ class GenericReader {
537
537
IterativeParsingState n = Predict (state_, t);
538
538
IterativeParsingState d = Transit<parseFlags>(state_, t, n, is, handler);
539
539
540
- if (d == IterativeParsingErrorState) {
541
- HandleError (state_, is);
542
- return false ;
543
- }
544
-
545
- state_ = d;
546
-
547
- // Do not further consume streams if we've parsed a complete object or hit an error.
548
- if (IsIterativeParsingCompleteState (state_)) {
549
- // If we hit an error, we are done.
550
- if (HasParseError ())
540
+ // If we've finished or hit an error...
541
+ if (IsIterativeParsingCompleteState (d)) {
542
+ // Report errors.
543
+ if (d == IterativeParsingErrorState) {
544
+ HandleError (state_, is);
551
545
return false ;
546
+ }
547
+
548
+ // Transition to the finish state.
549
+ RAPIDJSON_ASSERT (d == IterativeParsingFinishState);
550
+ state_ = d;
552
551
553
552
// If StopWhenDone is not set...
554
553
if (!(parseFlags & kParseStopWhenDoneFlag )) {
@@ -561,11 +560,14 @@ class GenericReader {
561
560
}
562
561
}
563
562
564
- // We are done!
563
+ // Success! We are done!
565
564
return true ;
566
565
}
567
566
568
- // If we found anything other than a delimiter, we invoked the handler, so we can return true now.
567
+ // Transition to the new state.
568
+ state_ = d;
569
+
570
+ // If we parsed anything other than a delimiter, we invoked the handler, so we can return true now.
569
571
if (!IsIterativeParsingDelimiterState (n))
570
572
return true ;
571
573
}
0 commit comments