(int ch)
| 879 | // return the next event when parser is in a neutral state (no |
| 880 | // map separators or array element separators to read |
| 881 | private int next(int ch) throws IOException { |
| 882 | // TODO: try my own form of indirect jump... look up char class and index directly into handling |
| 883 | // implementation? |
| 884 | for (; ; ) { |
| 885 | switch (ch) { |
| 886 | // this is not the exclusive list of whitespace chars... the rest are handled in default: |
| 887 | case ' ': |
| 888 | case '\t': |
| 889 | case '\r': |
| 890 | case '\n': |
| 891 | // calling getCharNWS here seems faster than letting the switch handle it |
| 892 | ch = getCharNWS(); |
| 893 | break; |
| 894 | case '"': |
| 895 | stringTerm = '"'; |
| 896 | valstate = STRING; |
| 897 | return STRING; |
| 898 | case '\'': |
| 899 | if ((flags & ALLOW_SINGLE_QUOTES) == 0) { |
| 900 | throw err("Single quoted strings not allowed"); |
| 901 | } |
| 902 | stringTerm = '\''; |
| 903 | valstate = STRING; |
| 904 | return STRING; |
| 905 | case '{': |
| 906 | push(); |
| 907 | state = DID_OBJSTART; |
| 908 | return OBJECT_START; |
| 909 | case '[': |
| 910 | push(); |
| 911 | state = DID_ARRSTART; |
| 912 | return ARRAY_START; |
| 913 | case '0': |
| 914 | out.reset(); |
| 915 | // special case '0'? If next char isn't '.' val=0 |
| 916 | ch = getChar(); |
| 917 | if (ch == '.') { |
| 918 | start--; |
| 919 | ch = '0'; |
| 920 | readNumber('0', false); |
| 921 | return valstate; |
| 922 | } else if (ch > '9' || ch < '0') { |
| 923 | out.unsafeWrite('0'); |
| 924 | if (ch != -1) start--; |
| 925 | lval = 0; |
| 926 | valstate = LONG; |
| 927 | return LONG; |
| 928 | } else { |
| 929 | throw err("Leading zeros not allowed"); |
| 930 | } |
| 931 | case '1': |
| 932 | case '2': |
| 933 | case '3': |
| 934 | case '4': |
| 935 | case '5': |
| 936 | case '6': |
| 937 | case '7': |
| 938 | case '8': |
no test coverage detected