Enum TokenType

  • All Implemented Interfaces:
    Serializable, Comparable<TokenType>

    public enum TokenType
    extends Enum<TokenType>
    The lexical token kinds of Java 11, declared in category order so the classification predicates can test ordinal ranges.
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
      ABSTRACT
      Modifier for a type or method declared without an implementation.
      AMP
      Bitwise or non-short-circuiting logical AND, and the separator between the bounds of an intersection type.
      AMP_AMP
      Conditional AND, which does not evaluate its right operand once the left is false.
      AMP_EQ
      Bitwise or logical AND into the target.
      ARROW
      Separates a lambda's parameters from its body, and an arrow-form switch label from its result.
      ASSERT
      Introduces an assert statement, whose check is inert unless assertions are enabled at run time.
      AT
      Introduces an annotation, and precedes the interface keyword in an annotation type declaration.
      BANG
      Logical negation.
      BANG_EQ
      Inequality test, the negation of EQ_EQ.
      BOOLEAN
      Primitive type keyword for a true/false value.
      BREAK
      Leaves the innermost loop or switch, or the labeled statement it names.
      BYTE
      Primitive type keyword for a signed 8-bit integer.
      CARET
      Bitwise or logical exclusive OR.
      CARET_EQ
      Bitwise exclusive OR into the target.
      CASE
      Introduces a switch label, in either colon or arrow form.
      CATCH
      Introduces a handler clause of a try statement.
      CHAR
      Primitive type keyword for an unsigned 16-bit UTF-16 code unit.
      CHAR_LITERAL
      A single-quoted character literal; the token also carries the decoded character value.
      CLASS
      Introduces a class declaration, and forms a class literal when it follows a type name.
      COLON
      Separates the arms of a conditional expression, terminates a colon-form switch label, and separates the parts of a for-each header or a statement label.
      COMMA
      Separates list elements such as parameters, arguments, declarators and type arguments.
      CONST
      Reserved by the language but unused, so it can only ever appear as a syntax error.
      CONTINUE
      Skips to the next iteration of the innermost loop, or of the loop its label names.
      DEFAULT
      The fall-through label of a switch, the modifier for an interface method carrying a body, and the marker before an annotation element's default value.
      DO
      Introduces a do-while loop, whose body runs once before the condition is first tested.
      DOT
      Member access, and the separator inside qualified names and imports.
      DOUBLE
      Primitive type keyword for a 64-bit IEEE 754 floating point value.
      DOUBLE_COLON
      Introduces a method or constructor reference.
      DOUBLE_LITERAL
      A numeric literal with a decimal point, an exponent, or a d suffix.
      ELLIPSIS
      Marks the last parameter of a method as varargs.
      ELSE
      The alternative branch of an if statement.
      ENUM
      Introduces an enum declaration.
      EOF
      End of input; emitted once when the source is exhausted so the parser always has a terminator to stop on.
      EQ
      Plain assignment; the only assignment operator outside the compound range, so isAssignmentOperator tests it separately.
      EQ_EQ
      Equality test, which on reference operands compares identity rather than contents.
      ERROR
      A sequence the lexer could not scan; the token's text is the diagnostic message rather than the offending source.
      EXTENDS
      Names a superclass, an interface's superinterfaces, or the upper bound of a type parameter or wildcard.
      FALSE
      The false boolean literal, grouped with the literals rather than the keywords.
      FINAL
      Modifier forbidding reassignment, overriding, or subclassing.
      FINALLY
      Introduces the clause of a try that runs on every exit path, normal or exceptional.
      FLOAT
      Primitive type keyword for a 32-bit IEEE 754 floating point value.
      FLOAT_LITERAL
      A numeric literal carrying an f or F suffix.
      FOR
      Introduces either a classic three-clause loop or a for-each loop.
      GOTO
      Reserved by the language but unused, so it can only ever appear as a syntax error.
      GT
      Greater-than test, and the closer of a type argument or type parameter list.
      GT_EQ
      Numeric greater-than-or-equal test.
      GT_GT
      Right shift that preserves the sign bit; the parser also splits this token back apart when it closes two nested type argument lists.
      GT_GT_EQ
      Sign-extending right-shifts the target in place.
      GT_GT_GT
      Right shift that fills with zeroes regardless of sign.
      GT_GT_GT_EQ
      Zero-filling right-shifts the target in place.
      IDENTIFIER
      Any name that is not a reserved word; it sits between the literals and the keywords so neither isLiteral nor isKeyword accepts it.
      IF
      Introduces a conditional statement.
      IMPLEMENTS
      Names the interfaces a class declares itself to satisfy.
      IMPORT
      Introduces an import declaration - single type, on demand, or static.
      INSTANCEOF
      Run-time type test; it is a keyword by position but isComparisonOperator counts it as a comparison.
      INT
      Primitive type keyword for a signed 32-bit integer.
      INTEGER_LITERAL
      An unsuffixed whole-number literal in any radix; one too large to fit an int is retyped as LONG_LITERAL instead of being rejected.
      INTERFACE
      Introduces an interface declaration, and follows AT in an annotation type declaration.
      LBRACE
      Opens a block, a type body, or an array initializer.
      LBRACKET
      Opens an array index, or a dimension in an array type or creation.
      LONG
      Primitive type keyword for a signed 64-bit integer.
      LONG_LITERAL
      A whole-number literal carrying an l or L suffix.
      LPAREN
      Opens a parenthesized expression, a parameter or argument list, or a cast.
      LT
      Less-than test, and the opener of a type argument or type parameter list.
      LT_EQ
      Numeric less-than-or-equal test.
      LT_LT
      Left shift.
      LT_LT_EQ
      Left-shifts the target in place.
      MINUS
      Subtraction or unary negation.
      MINUS_EQ
      Subtracts from the target in place.
      MINUS_MINUS
      Decrement by one, in either prefix or postfix position.
      NATIVE
      Modifier for a method whose implementation lives outside the JVM.
      NEW
      Introduces an instance creation, an array creation, or an anonymous class body.
      NULL
      The null reference literal, and the last kind isLiteral accepts.
      PACKAGE
      Introduces the package declaration at the head of a compilation unit.
      PERCENT
      Remainder of a division.
      PERCENT_EQ
      Replaces the target with the remainder of dividing it.
      PIPE
      Bitwise or non-short-circuiting logical OR, and the separator between the alternatives of a multi-catch clause.
      PIPE_EQ
      Bitwise or logical OR into the target.
      PIPE_PIPE
      Conditional OR, which does not evaluate its right operand once the left is true.
      PLUS
      Addition, string concatenation, or unary plus.
      PLUS_EQ
      Adds to the target in place; also the in-place string append.
      PLUS_PLUS
      Increment by one, in either prefix or postfix position.
      PRIVATE
      Access modifier limiting visibility to the declaring class.
      PROTECTED
      Access modifier granting visibility to subclasses and to the same package.
      PUBLIC
      Access modifier granting unrestricted visibility.
      QUESTION
      The condition separator of a conditional expression, and an unbounded wildcard type argument.
      RBRACE
      Closes the construct opened by the matching LBRACE.
      RBRACKET
      Closes the construct opened by the matching LBRACKET.
      RETURN
      Leaves the enclosing method or constructor, with a value unless it is void.
      RPAREN
      Closes the construct opened by the matching LPAREN.
      SEMICOLON
      Terminates a statement or declaration, and separates the clauses of a classic for loop.
      SHORT
      Primitive type keyword for a signed 16-bit integer.
      SLASH
      Division.
      SLASH_EQ
      Divides the target in place.
      STAR
      Multiplication, and the on-demand wildcard of an import.
      STAR_EQ
      Multiplies the target in place.
      STATIC
      Modifier binding a member to the type rather than to an instance; also appears in static imports and in initializer blocks.
      STRICTFP
      Modifier pinning floating point evaluation to strict IEEE 754 semantics.
      STRING_LITERAL
      A quoted string or text block; the token also carries the decoded contents, with escapes resolved and text-block indentation stripped.
      SUPER
      Refers to the superclass - as a qualifier, as a constructor call, or as the lower bound of a wildcard.
      SWITCH
      Introduces a switch statement or switch expression.
      SYNCHRONIZED
      Introduces a monitor-guarded block, or marks a method as guarded by its receiver's monitor.
      THIS
      Refers to the current instance, and heads a delegating constructor call to the same class.
      THROW
      Raises an exception, unwinding until a handler matches.
      THROWS
      Introduces the checked exception list of a method or constructor.
      TILDE
      Bitwise complement.
      TRANSIENT
      Modifier excluding a field from default serialization.
      TRUE
      The true boolean literal, grouped with the literals rather than the keywords, so isLiteral accepts it and isKeyword does not.
      TRY
      Introduces a try statement, with or without a resource list.
      VAR
      Requests an inferred local variable type; the lexer treats it as a reserved word even though the language allows it as an identifier.
      VOID
      Marks a method as producing no value, and names the void pseudo-type in a class literal.
      VOLATILE
      Modifier making a field's reads and writes immediately visible across threads.
      WHILE
      Introduces a while loop, and closes a do-while.
    • Enum Constant Detail

      • INTEGER_LITERAL

        public static final TokenType INTEGER_LITERAL
        An unsuffixed whole-number literal in any radix; one too large to fit an int is retyped as LONG_LITERAL instead of being rejected.
      • LONG_LITERAL

        public static final TokenType LONG_LITERAL
        A whole-number literal carrying an l or L suffix.
      • FLOAT_LITERAL

        public static final TokenType FLOAT_LITERAL
        A numeric literal carrying an f or F suffix.
      • DOUBLE_LITERAL

        public static final TokenType DOUBLE_LITERAL
        A numeric literal with a decimal point, an exponent, or a d suffix.
      • CHAR_LITERAL

        public static final TokenType CHAR_LITERAL
        A single-quoted character literal; the token also carries the decoded character value.
      • STRING_LITERAL

        public static final TokenType STRING_LITERAL
        A quoted string or text block; the token also carries the decoded contents, with escapes resolved and text-block indentation stripped.
      • TRUE

        public static final TokenType TRUE
        The true boolean literal, grouped with the literals rather than the keywords, so isLiteral accepts it and isKeyword does not.
      • FALSE

        public static final TokenType FALSE
        The false boolean literal, grouped with the literals rather than the keywords.
      • NULL

        public static final TokenType NULL
        The null reference literal, and the last kind isLiteral accepts.
      • IDENTIFIER

        public static final TokenType IDENTIFIER
        Any name that is not a reserved word; it sits between the literals and the keywords so neither isLiteral nor isKeyword accepts it.
      • ABSTRACT

        public static final TokenType ABSTRACT
        Modifier for a type or method declared without an implementation.
      • ASSERT

        public static final TokenType ASSERT
        Introduces an assert statement, whose check is inert unless assertions are enabled at run time.
      • BOOLEAN

        public static final TokenType BOOLEAN
        Primitive type keyword for a true/false value.
      • BREAK

        public static final TokenType BREAK
        Leaves the innermost loop or switch, or the labeled statement it names.
      • BYTE

        public static final TokenType BYTE
        Primitive type keyword for a signed 8-bit integer.
      • CASE

        public static final TokenType CASE
        Introduces a switch label, in either colon or arrow form.
      • CATCH

        public static final TokenType CATCH
        Introduces a handler clause of a try statement.
      • CHAR

        public static final TokenType CHAR
        Primitive type keyword for an unsigned 16-bit UTF-16 code unit.
      • CLASS

        public static final TokenType CLASS
        Introduces a class declaration, and forms a class literal when it follows a type name.
      • CONST

        public static final TokenType CONST
        Reserved by the language but unused, so it can only ever appear as a syntax error.
      • CONTINUE

        public static final TokenType CONTINUE
        Skips to the next iteration of the innermost loop, or of the loop its label names.
      • DEFAULT

        public static final TokenType DEFAULT
        The fall-through label of a switch, the modifier for an interface method carrying a body, and the marker before an annotation element's default value.
      • DO

        public static final TokenType DO
        Introduces a do-while loop, whose body runs once before the condition is first tested.
      • DOUBLE

        public static final TokenType DOUBLE
        Primitive type keyword for a 64-bit IEEE 754 floating point value.
      • ELSE

        public static final TokenType ELSE
        The alternative branch of an if statement.
      • ENUM

        public static final TokenType ENUM
        Introduces an enum declaration.
      • EXTENDS

        public static final TokenType EXTENDS
        Names a superclass, an interface's superinterfaces, or the upper bound of a type parameter or wildcard.
      • FINAL

        public static final TokenType FINAL
        Modifier forbidding reassignment, overriding, or subclassing.
      • FINALLY

        public static final TokenType FINALLY
        Introduces the clause of a try that runs on every exit path, normal or exceptional.
      • FLOAT

        public static final TokenType FLOAT
        Primitive type keyword for a 32-bit IEEE 754 floating point value.
      • FOR

        public static final TokenType FOR
        Introduces either a classic three-clause loop or a for-each loop.
      • GOTO

        public static final TokenType GOTO
        Reserved by the language but unused, so it can only ever appear as a syntax error.
      • IF

        public static final TokenType IF
        Introduces a conditional statement.
      • IMPLEMENTS

        public static final TokenType IMPLEMENTS
        Names the interfaces a class declares itself to satisfy.
      • IMPORT

        public static final TokenType IMPORT
        Introduces an import declaration - single type, on demand, or static.
      • INSTANCEOF

        public static final TokenType INSTANCEOF
        Run-time type test; it is a keyword by position but isComparisonOperator counts it as a comparison.
      • INT

        public static final TokenType INT
        Primitive type keyword for a signed 32-bit integer.
      • INTERFACE

        public static final TokenType INTERFACE
        Introduces an interface declaration, and follows AT in an annotation type declaration.
      • LONG

        public static final TokenType LONG
        Primitive type keyword for a signed 64-bit integer.
      • NATIVE

        public static final TokenType NATIVE
        Modifier for a method whose implementation lives outside the JVM.
      • NEW

        public static final TokenType NEW
        Introduces an instance creation, an array creation, or an anonymous class body.
      • PACKAGE

        public static final TokenType PACKAGE
        Introduces the package declaration at the head of a compilation unit.
      • PRIVATE

        public static final TokenType PRIVATE
        Access modifier limiting visibility to the declaring class.
      • PROTECTED

        public static final TokenType PROTECTED
        Access modifier granting visibility to subclasses and to the same package.
      • PUBLIC

        public static final TokenType PUBLIC
        Access modifier granting unrestricted visibility.
      • RETURN

        public static final TokenType RETURN
        Leaves the enclosing method or constructor, with a value unless it is void.
      • SHORT

        public static final TokenType SHORT
        Primitive type keyword for a signed 16-bit integer.
      • STATIC

        public static final TokenType STATIC
        Modifier binding a member to the type rather than to an instance; also appears in static imports and in initializer blocks.
      • STRICTFP

        public static final TokenType STRICTFP
        Modifier pinning floating point evaluation to strict IEEE 754 semantics.
      • SUPER

        public static final TokenType SUPER
        Refers to the superclass - as a qualifier, as a constructor call, or as the lower bound of a wildcard.
      • SWITCH

        public static final TokenType SWITCH
        Introduces a switch statement or switch expression.
      • SYNCHRONIZED

        public static final TokenType SYNCHRONIZED
        Introduces a monitor-guarded block, or marks a method as guarded by its receiver's monitor.
      • THIS

        public static final TokenType THIS
        Refers to the current instance, and heads a delegating constructor call to the same class.
      • THROW

        public static final TokenType THROW
        Raises an exception, unwinding until a handler matches.
      • THROWS

        public static final TokenType THROWS
        Introduces the checked exception list of a method or constructor.
      • TRANSIENT

        public static final TokenType TRANSIENT
        Modifier excluding a field from default serialization.
      • TRY

        public static final TokenType TRY
        Introduces a try statement, with or without a resource list.
      • VAR

        public static final TokenType VAR
        Requests an inferred local variable type; the lexer treats it as a reserved word even though the language allows it as an identifier.
      • VOID

        public static final TokenType VOID
        Marks a method as producing no value, and names the void pseudo-type in a class literal.
      • VOLATILE

        public static final TokenType VOLATILE
        Modifier making a field's reads and writes immediately visible across threads.
      • WHILE

        public static final TokenType WHILE
        Introduces a while loop, and closes a do-while.
      • PLUS

        public static final TokenType PLUS
        Addition, string concatenation, or unary plus.
      • MINUS

        public static final TokenType MINUS
        Subtraction or unary negation.
      • STAR

        public static final TokenType STAR
        Multiplication, and the on-demand wildcard of an import.
      • SLASH

        public static final TokenType SLASH
        Division.
      • PERCENT

        public static final TokenType PERCENT
        Remainder of a division.
      • AMP

        public static final TokenType AMP
        Bitwise or non-short-circuiting logical AND, and the separator between the bounds of an intersection type.
      • PIPE

        public static final TokenType PIPE
        Bitwise or non-short-circuiting logical OR, and the separator between the alternatives of a multi-catch clause.
      • CARET

        public static final TokenType CARET
        Bitwise or logical exclusive OR.
      • TILDE

        public static final TokenType TILDE
        Bitwise complement.
      • BANG

        public static final TokenType BANG
        Logical negation.
      • EQ

        public static final TokenType EQ
        Plain assignment; the only assignment operator outside the compound range, so isAssignmentOperator tests it separately.
      • LT

        public static final TokenType LT
        Less-than test, and the opener of a type argument or type parameter list.
      • GT

        public static final TokenType GT
        Greater-than test, and the closer of a type argument or type parameter list.
      • QUESTION

        public static final TokenType QUESTION
        The condition separator of a conditional expression, and an unbounded wildcard type argument.
      • COLON

        public static final TokenType COLON
        Separates the arms of a conditional expression, terminates a colon-form switch label, and separates the parts of a for-each header or a statement label.
      • ARROW

        public static final TokenType ARROW
        Separates a lambda's parameters from its body, and an arrow-form switch label from its result.
      • DOUBLE_COLON

        public static final TokenType DOUBLE_COLON
        Introduces a method or constructor reference.
      • PLUS_PLUS

        public static final TokenType PLUS_PLUS
        Increment by one, in either prefix or postfix position.
      • MINUS_MINUS

        public static final TokenType MINUS_MINUS
        Decrement by one, in either prefix or postfix position.
      • AMP_AMP

        public static final TokenType AMP_AMP
        Conditional AND, which does not evaluate its right operand once the left is false.
      • PIPE_PIPE

        public static final TokenType PIPE_PIPE
        Conditional OR, which does not evaluate its right operand once the left is true.
      • EQ_EQ

        public static final TokenType EQ_EQ
        Equality test, which on reference operands compares identity rather than contents.
      • BANG_EQ

        public static final TokenType BANG_EQ
        Inequality test, the negation of EQ_EQ.
      • LT_EQ

        public static final TokenType LT_EQ
        Numeric less-than-or-equal test.
      • GT_EQ

        public static final TokenType GT_EQ
        Numeric greater-than-or-equal test.
      • LT_LT

        public static final TokenType LT_LT
        Left shift.
      • GT_GT

        public static final TokenType GT_GT
        Right shift that preserves the sign bit; the parser also splits this token back apart when it closes two nested type argument lists.
      • GT_GT_GT

        public static final TokenType GT_GT_GT
        Right shift that fills with zeroes regardless of sign.
      • PLUS_EQ

        public static final TokenType PLUS_EQ
        Adds to the target in place; also the in-place string append.
      • MINUS_EQ

        public static final TokenType MINUS_EQ
        Subtracts from the target in place.
      • STAR_EQ

        public static final TokenType STAR_EQ
        Multiplies the target in place.
      • SLASH_EQ

        public static final TokenType SLASH_EQ
        Divides the target in place.
      • PERCENT_EQ

        public static final TokenType PERCENT_EQ
        Replaces the target with the remainder of dividing it.
      • AMP_EQ

        public static final TokenType AMP_EQ
        Bitwise or logical AND into the target.
      • PIPE_EQ

        public static final TokenType PIPE_EQ
        Bitwise or logical OR into the target.
      • CARET_EQ

        public static final TokenType CARET_EQ
        Bitwise exclusive OR into the target.
      • LT_LT_EQ

        public static final TokenType LT_LT_EQ
        Left-shifts the target in place.
      • GT_GT_EQ

        public static final TokenType GT_GT_EQ
        Sign-extending right-shifts the target in place.
      • GT_GT_GT_EQ

        public static final TokenType GT_GT_GT_EQ
        Zero-filling right-shifts the target in place.
      • LPAREN

        public static final TokenType LPAREN
        Opens a parenthesized expression, a parameter or argument list, or a cast.
      • RPAREN

        public static final TokenType RPAREN
        Closes the construct opened by the matching LPAREN.
      • LBRACE

        public static final TokenType LBRACE
        Opens a block, a type body, or an array initializer.
      • RBRACE

        public static final TokenType RBRACE
        Closes the construct opened by the matching LBRACE.
      • LBRACKET

        public static final TokenType LBRACKET
        Opens an array index, or a dimension in an array type or creation.
      • RBRACKET

        public static final TokenType RBRACKET
        Closes the construct opened by the matching LBRACKET.
      • SEMICOLON

        public static final TokenType SEMICOLON
        Terminates a statement or declaration, and separates the clauses of a classic for loop.
      • COMMA

        public static final TokenType COMMA
        Separates list elements such as parameters, arguments, declarators and type arguments.
      • DOT

        public static final TokenType DOT
        Member access, and the separator inside qualified names and imports.
      • AT

        public static final TokenType AT
        Introduces an annotation, and precedes the interface keyword in an annotation type declaration.
      • ELLIPSIS

        public static final TokenType ELLIPSIS
        Marks the last parameter of a method as varargs.
      • EOF

        public static final TokenType EOF
        End of input; emitted once when the source is exhausted so the parser always has a terminator to stop on.
      • ERROR

        public static final TokenType ERROR
        A sequence the lexer could not scan; the token's text is the diagnostic message rather than the offending source.
    • Method Detail

      • values

        public static TokenType[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (TokenType c : TokenType.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static TokenType valueOf​(String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        IllegalArgumentException - if this enum type has no constant with the specified name
        NullPointerException - if the argument is null
      • isKeyword

        public boolean isKeyword()
        Returns:
        true for a reserved word, ABSTRACT through WHILE
      • isLiteral

        public boolean isLiteral()
        Returns:
        true for a literal, including the true, false and null keywords
      • isAssignmentOperator

        public boolean isAssignmentOperator()
        Returns:
        true for plain assignment or any compound assignment operator
      • isComparisonOperator

        public boolean isComparisonOperator()
        Returns:
        true for an equality or relational operator, counting instanceof
      • isPrimitiveType

        public boolean isPrimitiveType()
        Returns:
        true for one of the eight primitive type keywords
      • isModifier

        public boolean isModifier()
        Returns:
        true for a declaration modifier keyword