| 662 | } |
| 663 | |
| 664 | bool Reader::readArray(Token& tokenStart) { |
| 665 | Value init(arrayValue); |
| 666 | currentValue().swapPayload(init); |
| 667 | currentValue().setOffsetStart(tokenStart.start_ - begin_); |
| 668 | skipSpaces(); |
| 669 | if (*current_ == ']') // empty array |
| 670 | { |
| 671 | Token endArray; |
| 672 | readToken(endArray); |
| 673 | return true; |
| 674 | } |
| 675 | int index = 0; |
| 676 | for (;;) { |
| 677 | Value& value = currentValue()[index++]; |
| 678 | nodes_.push(&value); |
| 679 | bool ok = readValue(); |
| 680 | nodes_.pop(); |
| 681 | if (!ok) // error already set |
| 682 | return recoverFromError(tokenArrayEnd); |
| 683 | |
| 684 | Token token; |
| 685 | // Accept Comment after last item in the array. |
| 686 | ok = readToken(token); |
| 687 | while (token.type_ == tokenComment && ok) { |
| 688 | ok = readToken(token); |
| 689 | } |
| 690 | bool badTokenType = |
| 691 | (token.type_ != tokenArraySeparator && token.type_ != tokenArrayEnd); |
| 692 | if (!ok || badTokenType) { |
| 693 | return addErrorAndRecover( |
| 694 | "Missing ',' or ']' in array declaration", token, tokenArrayEnd); |
| 695 | } |
| 696 | if (token.type_ == tokenArrayEnd) |
| 697 | break; |
| 698 | } |
| 699 | return true; |
| 700 | } |
| 701 | |
| 702 | bool Reader::decodeNumber(Token& token) { |
| 703 | Value decoded; |
nothing calls this directly
no test coverage detected