()
| 649 | } |
| 650 | |
| 651 | public Token nextToken() throws ParseException { |
| 652 | if (!pushBack.isEmpty()) { |
| 653 | return pushBack.removeFirst(); |
| 654 | } |
| 655 | |
| 656 | while (!isAtEnd()) { |
| 657 | char ch = advance(); |
| 658 | switch (ch) { |
| 659 | case '\n': |
| 660 | line++; |
| 661 | start++; |
| 662 | break; |
| 663 | case ' ': |
| 664 | case '\r': |
| 665 | case '\t': |
| 666 | start++; |
| 667 | break; |
| 668 | case ':': |
| 669 | return token(TokenType.COLON); |
| 670 | case '{': |
| 671 | return token(TokenType.LEFT_CURLY); |
| 672 | case '}': |
| 673 | return token(TokenType.RIGHT_CURLY); |
| 674 | case '[': |
| 675 | return token(TokenType.LEFT_BRACKET); |
| 676 | case ']': |
| 677 | return token(TokenType.RIGHT_BACKET); |
| 678 | case '"': |
| 679 | return stringToken(); |
| 680 | case '-': |
| 681 | case '+': |
| 682 | case '0': |
| 683 | case '1': |
| 684 | case '2': |
| 685 | case '3': |
| 686 | case '4': |
| 687 | case '5': |
| 688 | case '6': |
| 689 | case '7': |
| 690 | case '8': |
| 691 | case '9': |
| 692 | return numberToken(ch); |
| 693 | case 'n': |
| 694 | return advanceMatching("ull", false, TokenType.NULL); |
| 695 | case 't': |
| 696 | return advanceMatching("rue", false, TokenType.TRUE); |
| 697 | case 'f': |
| 698 | return advanceMatching("alse", false, TokenType.FALSE); |
| 699 | case ',': |
| 700 | return token(TokenType.COMMA); |
| 701 | } |
| 702 | } |
| 703 | return token(TokenType.EOF); |
| 704 | } |
| 705 | |
| 706 | private Token numberToken(char ch) { |
| 707 | StringBuilder ret = new StringBuilder(); |
no test coverage detected