| 798 | } |
| 799 | |
| 800 | bool Reader::readArray(Token &token) |
| 801 | { |
| 802 | Value init(arrayValue); |
| 803 | currentValue().swapPayload(init); |
| 804 | currentValue().setOffsetStart(token.start_ - begin_); |
| 805 | skipSpaces(); |
| 806 | if (current_ != end_ && *current_ == ']') // empty array |
| 807 | { |
| 808 | Token endArray; |
| 809 | readToken(endArray); |
| 810 | return true; |
| 811 | } |
| 812 | int index = 0; |
| 813 | for (;;) |
| 814 | { |
| 815 | Value &value = currentValue()[index++]; |
| 816 | nodes_.push(&value); |
| 817 | bool ok = readValue(); |
| 818 | nodes_.pop(); |
| 819 | if (!ok) // error already set |
| 820 | return recoverFromError(tokenArrayEnd); |
| 821 | |
| 822 | Token currentToken; |
| 823 | // Accept Comment after last item in the array. |
| 824 | ok = readToken(currentToken); |
| 825 | while (currentToken.type_ == tokenComment && ok) |
| 826 | { |
| 827 | ok = readToken(currentToken); |
| 828 | } |
| 829 | bool badTokenType = |
| 830 | (currentToken.type_ != tokenArraySeparator && currentToken.type_ != tokenArrayEnd); |
| 831 | if (!ok || badTokenType) |
| 832 | { |
| 833 | return addErrorAndRecover("Missing ',' or ']' in array declaration", currentToken, |
| 834 | tokenArrayEnd); |
| 835 | } |
| 836 | if (currentToken.type_ == tokenArrayEnd) |
| 837 | break; |
| 838 | } |
| 839 | return true; |
| 840 | } |
| 841 | |
| 842 | bool Reader::decodeNumber(Token &token) |
| 843 | { |
nothing calls this directly
no test coverage detected