| 509 | } |
| 510 | |
| 511 | bool Reader::readArray(Token& token) { |
| 512 | Value init(arrayValue); |
| 513 | currentValue().swapPayload(init); |
| 514 | currentValue().setOffsetStart(token.start_ - begin_); |
| 515 | skipSpaces(); |
| 516 | if (current_ != end_ && *current_ == ']') // empty array |
| 517 | { |
| 518 | Token endArray; |
| 519 | readToken(endArray); |
| 520 | return true; |
| 521 | } |
| 522 | int index = 0; |
| 523 | for (;;) { |
| 524 | Value& value = currentValue()[index++]; |
| 525 | nodes_.push(&value); |
| 526 | bool ok = readValue(); |
| 527 | nodes_.pop(); |
| 528 | if (!ok) // error already set |
| 529 | return recoverFromError(tokenArrayEnd); |
| 530 | |
| 531 | Token currentToken; |
| 532 | // Accept Comment after last item in the array. |
| 533 | ok = readToken(currentToken); |
| 534 | while (currentToken.type_ == tokenComment && ok) { |
| 535 | ok = readToken(currentToken); |
| 536 | } |
| 537 | bool badTokenType = (currentToken.type_ != tokenArraySeparator && |
| 538 | currentToken.type_ != tokenArrayEnd); |
| 539 | if (!ok || badTokenType) { |
| 540 | return addErrorAndRecover("Missing ',' or ']' in array declaration", |
| 541 | currentToken, tokenArrayEnd); |
| 542 | } |
| 543 | if (currentToken.type_ == tokenArrayEnd) |
| 544 | break; |
| 545 | } |
| 546 | return true; |
| 547 | } |
| 548 | |
| 549 | bool Reader::decodeNumber(Token& token) { |
| 550 | Value decoded; |
nothing calls this directly
no test coverage detected