| 700 | } |
| 701 | |
| 702 | bool Reader::readArray(Token& tokenStart) { |
| 703 | Value init(arrayValue); |
| 704 | currentValue().swapPayload(init); |
| 705 | currentValue().setOffsetStart(tokenStart.start_ - begin_); |
| 706 | skipSpaces(); |
| 707 | if (*current_ == ']') // empty array |
| 708 | { |
| 709 | Token endArray; |
| 710 | readToken(endArray); |
| 711 | return true; |
| 712 | } |
| 713 | int index = 0; |
| 714 | for (;;) { |
| 715 | Value& value = currentValue()[index++]; |
| 716 | nodes_.push(&value); |
| 717 | bool ok = readValue(); |
| 718 | nodes_.pop(); |
| 719 | if (!ok) // error already set |
| 720 | return recoverFromError(tokenArrayEnd); |
| 721 | |
| 722 | Token token; |
| 723 | // Accept Comment after last item in the array. |
| 724 | ok = readToken(token); |
| 725 | while (token.type_ == tokenComment && ok) { |
| 726 | ok = readToken(token); |
| 727 | } |
| 728 | bool badTokenType = |
| 729 | (token.type_ != tokenArraySeparator && token.type_ != tokenArrayEnd); |
| 730 | if (!ok || badTokenType) { |
| 731 | return addErrorAndRecover( |
| 732 | "Missing ',' or ']' in array declaration", token, tokenArrayEnd); |
| 733 | } |
| 734 | if (token.type_ == tokenArrayEnd) |
| 735 | break; |
| 736 | } |
| 737 | return true; |
| 738 | } |
| 739 | |
| 740 | bool Reader::decodeNumber(Token& token) { |
| 741 | Value decoded; |
nothing calls this directly
no test coverage detected