| 249 | } |
| 250 | |
| 251 | JSON::Array* JSON::Parser::ParseArray(const std::string & textFile) |
| 252 | { |
| 253 | JSON::Array* ret = new JSON::Array; |
| 254 | bool parseSuccess = false; |
| 255 | bool parseFail = false; |
| 256 | bool prevVal = false; |
| 257 | bool prevDelim = false; |
| 258 | while (!m_Completed && !parseSuccess && !parseFail) |
| 259 | { |
| 260 | MoveToNonWhitespace(textFile); |
| 261 | if(CheckEOF(textFile))continue; |
| 262 | Token token = ReadToken(textFile); |
| 263 | if(!(token == JT_Delim) && !(token == JT_EndArray) && !(token == JT_Numeric))m_ReadIdx--; |
| 264 | if(CheckEOF(textFile))continue; |
| 265 | switch (token) |
| 266 | { |
| 267 | case JT_EndArray: |
| 268 | if(prevDelim) |
| 269 | { |
| 270 | LOG("Expected a new Key Value pair after delimiter", Warning); |
| 271 | parseFail = true; |
| 272 | continue; |
| 273 | } |
| 274 | parseSuccess = true; |
| 275 | break; |
| 276 | case JT_Delim: |
| 277 | if (!prevVal) |
| 278 | { |
| 279 | LOG("Expected a new Key Value pair before delimiter", Warning); |
| 280 | parseFail = true; |
| 281 | continue; |
| 282 | } |
| 283 | prevVal = false; |
| 284 | prevDelim = true; |
| 285 | continue; |
| 286 | default: |
| 287 | if (!prevVal) |
| 288 | { |
| 289 | JSON::Value* val = ParseValue(textFile); |
| 290 | prevDelim = false; |
| 291 | if (val) |
| 292 | { |
| 293 | ret->value.push_back(val); |
| 294 | prevVal = true; |
| 295 | continue; |
| 296 | } |
| 297 | } |
| 298 | else |
| 299 | LOG("Expected a delimiter before new Key Value pair", Warning); |
| 300 | parseFail = true; |
| 301 | continue; |
| 302 | } |
| 303 | } |
| 304 | if (!parseSuccess) |
| 305 | { |
| 306 | delete ret; |
| 307 | LOG("Couldn't successfully parse array", Warning); |
| 308 | return nullptr; |
nothing calls this directly
no outgoing calls
no test coverage detected