| 488 | } |
| 489 | |
| 490 | bool Reader::readArray(Token& token) { |
| 491 | Value init(arrayValue); |
| 492 | currentValue().swapPayload(init); |
| 493 | currentValue().setOffsetStart(token.start_ - begin_); |
| 494 | skipSpaces(); |
| 495 | if (current_ != end_ && *current_ == ']') // empty array |
| 496 | { |
| 497 | Token endArray; |
| 498 | readToken(endArray); |
| 499 | return true; |
| 500 | } |
| 501 | int index = 0; |
| 502 | for (;;) { |
| 503 | Value& value = currentValue()[index++]; |
| 504 | nodes_.push(&value); |
| 505 | bool ok = readValue(); |
| 506 | nodes_.pop(); |
| 507 | if (!ok) // error already set |
| 508 | return recoverFromError(tokenArrayEnd); |
| 509 | |
| 510 | Token currentToken; |
| 511 | // Accept Comment after last item in the array. |
| 512 | ok = readTokenSkippingComments(currentToken); |
| 513 | bool badTokenType = (currentToken.type_ != tokenArraySeparator && |
| 514 | currentToken.type_ != tokenArrayEnd); |
| 515 | if (!ok || badTokenType) { |
| 516 | return addErrorAndRecover("Missing ',' or ']' in array declaration", |
| 517 | currentToken, tokenArrayEnd); |
| 518 | } |
| 519 | if (currentToken.type_ == tokenArrayEnd) |
| 520 | break; |
| 521 | } |
| 522 | return true; |
| 523 | } |
| 524 | |
| 525 | bool Reader::decodeNumber(Token& token) { |
| 526 | Value decoded; |
nothing calls this directly
no test coverage detected