| 646 | } |
| 647 | |
| 648 | bool Reader::readArray(Token& /*tokenStart*/) { |
| 649 | Value init(arrayValue); |
| 650 | currentValue().swapPayload(init); |
| 651 | skipSpaces(); |
| 652 | if (*current_ == ']') // empty array |
| 653 | { |
| 654 | Token endArray; |
| 655 | readToken(endArray); |
| 656 | return true; |
| 657 | } |
| 658 | int index = 0; |
| 659 | for (;;) { |
| 660 | Value& value = currentValue()[index++]; |
| 661 | nodes_.push(&value); |
| 662 | bool ok = readValue(); |
| 663 | nodes_.pop(); |
| 664 | if (!ok) // error already set |
| 665 | return recoverFromError(tokenArrayEnd); |
| 666 | |
| 667 | Token token; |
| 668 | // Accept Comment after last item in the array. |
| 669 | ok = readToken(token); |
| 670 | while (token.type_ == tokenComment && ok) { |
| 671 | ok = readToken(token); |
| 672 | } |
| 673 | bool badTokenType = |
| 674 | (token.type_ != tokenArraySeparator && token.type_ != tokenArrayEnd); |
| 675 | if (!ok || badTokenType) { |
| 676 | return addErrorAndRecover( |
| 677 | "Missing ',' or ']' in array declaration", token, tokenArrayEnd); |
| 678 | } |
| 679 | if (token.type_ == tokenArrayEnd) |
| 680 | break; |
| 681 | } |
| 682 | return true; |
| 683 | } |
| 684 | |
| 685 | bool Reader::decodeNumber(Token& token) { |
| 686 | Value decoded; |
nothing calls this directly
no test coverage detected