| 753 | } |
| 754 | |
| 755 | bool Reader::readArray(Token& tokenStart) { |
| 756 | Value init(arrayValue); |
| 757 | currentValue().swapPayload(init); |
| 758 | currentValue().setOffsetStart(tokenStart.start_ - begin_); |
| 759 | skipSpaces(); |
| 760 | if (current_ != end_ && *current_ == ']') // empty array |
| 761 | { |
| 762 | Token endArray; |
| 763 | readToken(endArray); |
| 764 | return true; |
| 765 | } |
| 766 | int index = 0; |
| 767 | for (;;) { |
| 768 | Value& value = currentValue()[index++]; |
| 769 | nodes_.push(&value); |
| 770 | bool ok = readValue(); |
| 771 | nodes_.pop(); |
| 772 | if (!ok) // error already set |
| 773 | return recoverFromError(tokenArrayEnd); |
| 774 | |
| 775 | Token token; |
| 776 | // Accept Comment after last item in the array. |
| 777 | ok = readToken(token); |
| 778 | while (token.type_ == tokenComment && ok) { |
| 779 | ok = readToken(token); |
| 780 | } |
| 781 | bool badTokenType = |
| 782 | (token.type_ != tokenArraySeparator && token.type_ != tokenArrayEnd); |
| 783 | if (!ok || badTokenType) { |
| 784 | return addErrorAndRecover("Missing ',' or ']' in array declaration", |
| 785 | token, tokenArrayEnd); |
| 786 | } |
| 787 | if (token.type_ == tokenArrayEnd) |
| 788 | break; |
| 789 | } |
| 790 | return true; |
| 791 | } |
| 792 | |
| 793 | bool Reader::decodeNumber(Token& token) { |
| 794 | Value decoded; |
nothing calls this directly
no test coverage detected