| 734 | } |
| 735 | |
| 736 | bool Reader::readArray(Token& tokenStart) { |
| 737 | Value init(arrayValue); |
| 738 | currentValue().swapPayload(init); |
| 739 | currentValue().setOffsetStart(tokenStart.start_ - begin_); |
| 740 | skipSpaces(); |
| 741 | if (current_ != end_ && *current_ == ']') // empty array |
| 742 | { |
| 743 | Token endArray; |
| 744 | readToken(endArray); |
| 745 | return true; |
| 746 | } |
| 747 | int index = 0; |
| 748 | for (;;) { |
| 749 | Value& value = currentValue()[index++]; |
| 750 | nodes_.push(&value); |
| 751 | bool ok = readValue(); |
| 752 | nodes_.pop(); |
| 753 | if (!ok) // error already set |
| 754 | return recoverFromError(tokenArrayEnd); |
| 755 | |
| 756 | Token token; |
| 757 | // Accept Comment after last item in the array. |
| 758 | ok = readToken(token); |
| 759 | while (token.type_ == tokenComment && ok) { |
| 760 | ok = readToken(token); |
| 761 | } |
| 762 | bool badTokenType = |
| 763 | (token.type_ != tokenArraySeparator && token.type_ != tokenArrayEnd); |
| 764 | if (!ok || badTokenType) { |
| 765 | return addErrorAndRecover( |
| 766 | "Missing ',' or ']' in array declaration", token, tokenArrayEnd); |
| 767 | } |
| 768 | if (token.type_ == tokenArrayEnd) |
| 769 | break; |
| 770 | } |
| 771 | return true; |
| 772 | } |
| 773 | |
| 774 | bool Reader::decodeNumber(Token& token) { |
| 775 | Value decoded; |
nothing calls this directly
no test coverage detected