Reader: drop object/array root restrction from iterative parser

This commit is contained in:
Philipp A. Hartmann 2014-08-11 15:24:56 +02:00
parent edccda00bd
commit c9f2715115

View File

@ -903,6 +903,9 @@ private:
IterativeParsingElementDelimiterState, IterativeParsingElementDelimiterState,
IterativeParsingArrayFinishState, IterativeParsingArrayFinishState,
// Single value state
IterativeParsingValueState,
cIterativeParsingStateCount cIterativeParsingStateCount
}; };
@ -961,11 +964,11 @@ private:
IterativeParsingErrorState, // Right curly bracket IterativeParsingErrorState, // Right curly bracket
IterativeParsingErrorState, // Comma IterativeParsingErrorState, // Comma
IterativeParsingErrorState, // Colon IterativeParsingErrorState, // Colon
IterativeParsingErrorState, // String IterativeParsingValueState, // String
IterativeParsingErrorState, // False IterativeParsingValueState, // False
IterativeParsingErrorState, // True IterativeParsingValueState, // True
IterativeParsingErrorState, // Null IterativeParsingValueState, // Null
IterativeParsingErrorState // Number IterativeParsingValueState // Number
}, },
// Finish(sink state) // Finish(sink state)
{ {
@ -1102,6 +1105,12 @@ private:
IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState,
IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState,
IterativeParsingErrorState IterativeParsingErrorState
},
// Single Value (sink state)
{
IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState,
IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState, IterativeParsingErrorState,
IterativeParsingErrorState
} }
}; // End of G }; // End of G
@ -1238,6 +1247,14 @@ private:
} }
} }
case IterativeParsingValueState:
// Must be non-compound value. Or it would be ObjectInitial or ArrayInitial state.
ParseValue<parseFlags>(is, handler);
if (HasParseError()) {
return IterativeParsingErrorState;
}
return IterativeParsingFinishState;
default: default:
RAPIDJSON_ASSERT(false); RAPIDJSON_ASSERT(false);
return IterativeParsingErrorState; return IterativeParsingErrorState;
@ -1252,7 +1269,7 @@ private:
} }
switch (src) { switch (src) {
case IterativeParsingStartState: RAPIDJSON_PARSE_ERROR(is.Peek() == '\0' ? kParseErrorDocumentEmpty : kParseErrorDocumentRootNotObjectOrArray, is.Tell()); case IterativeParsingStartState: RAPIDJSON_PARSE_ERROR(kParseErrorDocumentEmpty, is.Tell());
case IterativeParsingFinishState: RAPIDJSON_PARSE_ERROR(kParseErrorDocumentRootNotSingular, is.Tell()); case IterativeParsingFinishState: RAPIDJSON_PARSE_ERROR(kParseErrorDocumentRootNotSingular, is.Tell());
case IterativeParsingObjectInitialState: case IterativeParsingObjectInitialState:
case IterativeParsingMemberDelimiterState: RAPIDJSON_PARSE_ERROR(kParseErrorObjectMissName, is.Tell()); case IterativeParsingMemberDelimiterState: RAPIDJSON_PARSE_ERROR(kParseErrorObjectMissName, is.Tell());