public final int nextToken()

in src/com/amazon/ion/impl/IonReaderTextRawTokensX.java [603:719]


    public final int nextToken() throws IOException
    {
        int t = -1;
        int c, c2;

        if (_unfinished_token) {
            c = skip_to_end(null);
        }
        else {
            c = skip_over_whitespace();
        }
        _unfinished_token = true;

        switch (c) {
        case -1:
            return next_token_finish(IonTokenConstsX.TOKEN_EOF, true);
        case '/':
            unread_char(c);
            return next_token_finish(IonTokenConstsX.TOKEN_SYMBOL_OPERATOR, true);
        case ':':
            c2 = read_char();
            if (c2 != ':') {
                unread_char(c2);
                return next_token_finish(IonTokenConstsX.TOKEN_COLON, true);
            }
            return next_token_finish(IonTokenConstsX.TOKEN_DOUBLE_COLON, true);
        case '{':
            c2 = read_char();
            if (c2 != '{') {
                unread_char(c2);
                return next_token_finish(IonTokenConstsX.TOKEN_OPEN_BRACE, true); // CAS: 9 nov 2009
            }
            return next_token_finish(IonTokenConstsX.TOKEN_OPEN_DOUBLE_BRACE, true);
        case '}':
            // detection of double closing braces is done
            // in the parser in the blob and clob handling
            // state - it's otherwise ambiguous with closing
            // two structs together. see tryForDoubleBrace() below
            return next_token_finish(IonTokenConstsX.TOKEN_CLOSE_BRACE, false);
        case '[':
            return next_token_finish(IonTokenConstsX.TOKEN_OPEN_SQUARE, true); // CAS: 9 nov 2009
        case ']':
            return next_token_finish(IonTokenConstsX.TOKEN_CLOSE_SQUARE, false);
        case '(':
            return next_token_finish(IonTokenConstsX.TOKEN_OPEN_PAREN, true); // CAS: 9 nov 2009
        case ')':
            return next_token_finish(IonTokenConstsX.TOKEN_CLOSE_PAREN, false);
        case ',':
            return next_token_finish(IonTokenConstsX.TOKEN_COMMA, false);
        case '.':
            c2 = read_char();
            unread_char(c2);
            if (IonTokenConstsX.isValidExtendedSymbolCharacter(c2)) {
                unread_char('.');
                return next_token_finish(IonTokenConstsX.TOKEN_SYMBOL_OPERATOR, true);
            }
            return next_token_finish(IonTokenConstsX.TOKEN_DOT, false);
        case '\'':
            if (is_2_single_quotes_helper()) {
                return next_token_finish(IonTokenConstsX.TOKEN_STRING_TRIPLE_QUOTE, true);
            }
            // unread_char(c);
            return next_token_finish(IonTokenConstsX.TOKEN_SYMBOL_QUOTED, true);
        case '+':
            if (peek_inf_helper(c)) // this will consume the inf if it succeeds
            {
                return next_token_finish(IonTokenConstsX.TOKEN_FLOAT_INF, false);
            }
            unread_char(c);
            return next_token_finish(IonTokenConstsX.TOKEN_SYMBOL_OPERATOR, true);
        case '#':
        case '<': case '>': case '*': case '=': case '^': case '&': case '|':
        case '~': case ';': case '!': case '?': case '@': case '%': case '`':
            unread_char(c);
            return next_token_finish(IonTokenConstsX.TOKEN_SYMBOL_OPERATOR, true);
        case '"':
            return next_token_finish(IonTokenConstsX.TOKEN_STRING_DOUBLE_QUOTE, true);
        case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
        case 'g': case 'h': case 'i': case 'j': case 'k': case 'l':
        case 'm': case 'n': case 'o': case 'p': case 'q': case 'r':
        case 's': case 't': case 'u': case 'v': case 'w': case 'x':
        case 'y': case 'z':
        case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
        case 'G': case 'H': case 'I': case 'J': case 'K': case 'L':
        case 'M': case 'N': case 'O': case 'P': case 'Q': case 'R':
        case 'S': case 'T': case 'U': case 'V': case 'W': case 'X':
        case 'Y': case 'Z':
        case '$': case '_':
            unread_char(c);
            return next_token_finish(IonTokenConstsX.TOKEN_SYMBOL_IDENTIFIER, true);
        case '0': case '1': case '2': case '3': case '4':
        case '5': case '6': case '7': case '8': case '9':
            t = scan_for_numeric_type(c);
            unread_char(c);
            return next_token_finish(t, true);
        case '-':
            // see if we have a number or what might be an extended symbol
            c2 = read_char();
            unread_char(c2);
            if (IonTokenConstsX.isDigit(c2)) {
                t = scan_negative_for_numeric_type(c);
                unread_char(c);
                return next_token_finish(t, true);
            }
            else if (peek_inf_helper(c)) // this will consume the inf if it succeeds
            {
                return next_token_finish(IonTokenConstsX.TOKEN_FLOAT_MINUS_INF, false);
            }
            else {
                unread_char(c);
                return next_token_finish(IonTokenConstsX.TOKEN_SYMBOL_OPERATOR, true);
            }
        default:
            bad_token_start(c); // throws
        }
        throw new IonException("invalid state: next token switch shouldn't exit");
    }