Package com.tonic.analysis.source.parser
Enum TokenType
- java.lang.Object
-
- java.lang.Enum<TokenType>
-
- com.tonic.analysis.source.parser.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 ABSTRACTModifier for a type or method declared without an implementation.AMPBitwise or non-short-circuiting logical AND, and the separator between the bounds of an intersection type.AMP_AMPConditional AND, which does not evaluate its right operand once the left is false.AMP_EQBitwise or logical AND into the target.ARROWSeparates a lambda's parameters from its body, and an arrow-form switch label from its result.ASSERTIntroduces an assert statement, whose check is inert unless assertions are enabled at run time.ATIntroduces an annotation, and precedes the interface keyword in an annotation type declaration.BANGLogical negation.BANG_EQInequality test, the negation of EQ_EQ.BOOLEANPrimitive type keyword for a true/false value.BREAKLeaves the innermost loop or switch, or the labeled statement it names.BYTEPrimitive type keyword for a signed 8-bit integer.CARETBitwise or logical exclusive OR.CARET_EQBitwise exclusive OR into the target.CASEIntroduces a switch label, in either colon or arrow form.CATCHIntroduces a handler clause of a try statement.CHARPrimitive type keyword for an unsigned 16-bit UTF-16 code unit.CHAR_LITERALA single-quoted character literal; the token also carries the decoded character value.CLASSIntroduces a class declaration, and forms a class literal when it follows a type name.COLONSeparates 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.COMMASeparates list elements such as parameters, arguments, declarators and type arguments.CONSTReserved by the language but unused, so it can only ever appear as a syntax error.CONTINUESkips to the next iteration of the innermost loop, or of the loop its label names.DEFAULTThe 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.DOIntroduces a do-while loop, whose body runs once before the condition is first tested.DOTMember access, and the separator inside qualified names and imports.DOUBLEPrimitive type keyword for a 64-bit IEEE 754 floating point value.DOUBLE_COLONIntroduces a method or constructor reference.DOUBLE_LITERALA numeric literal with a decimal point, an exponent, or a d suffix.ELLIPSISMarks the last parameter of a method as varargs.ELSEThe alternative branch of an if statement.ENUMIntroduces an enum declaration.EOFEnd of input; emitted once when the source is exhausted so the parser always has a terminator to stop on.EQPlain assignment; the only assignment operator outside the compound range, so isAssignmentOperator tests it separately.EQ_EQEquality test, which on reference operands compares identity rather than contents.ERRORA sequence the lexer could not scan; the token's text is the diagnostic message rather than the offending source.EXTENDSNames a superclass, an interface's superinterfaces, or the upper bound of a type parameter or wildcard.FALSEThe false boolean literal, grouped with the literals rather than the keywords.FINALModifier forbidding reassignment, overriding, or subclassing.FINALLYIntroduces the clause of a try that runs on every exit path, normal or exceptional.FLOATPrimitive type keyword for a 32-bit IEEE 754 floating point value.FLOAT_LITERALA numeric literal carrying an f or F suffix.FORIntroduces either a classic three-clause loop or a for-each loop.GOTOReserved by the language but unused, so it can only ever appear as a syntax error.GTGreater-than test, and the closer of a type argument or type parameter list.GT_EQNumeric greater-than-or-equal test.GT_GTRight shift that preserves the sign bit; the parser also splits this token back apart when it closes two nested type argument lists.GT_GT_EQSign-extending right-shifts the target in place.GT_GT_GTRight shift that fills with zeroes regardless of sign.GT_GT_GT_EQZero-filling right-shifts the target in place.IDENTIFIERAny name that is not a reserved word; it sits between the literals and the keywords so neither isLiteral nor isKeyword accepts it.IFIntroduces a conditional statement.IMPLEMENTSNames the interfaces a class declares itself to satisfy.IMPORTIntroduces an import declaration - single type, on demand, or static.INSTANCEOFRun-time type test; it is a keyword by position but isComparisonOperator counts it as a comparison.INTPrimitive type keyword for a signed 32-bit integer.INTEGER_LITERALAn unsuffixed whole-number literal in any radix; one too large to fit an int is retyped as LONG_LITERAL instead of being rejected.INTERFACEIntroduces an interface declaration, and follows AT in an annotation type declaration.LBRACEOpens a block, a type body, or an array initializer.LBRACKETOpens an array index, or a dimension in an array type or creation.LONGPrimitive type keyword for a signed 64-bit integer.LONG_LITERALA whole-number literal carrying an l or L suffix.LPARENOpens a parenthesized expression, a parameter or argument list, or a cast.LTLess-than test, and the opener of a type argument or type parameter list.LT_EQNumeric less-than-or-equal test.LT_LTLeft shift.LT_LT_EQLeft-shifts the target in place.MINUSSubtraction or unary negation.MINUS_EQSubtracts from the target in place.MINUS_MINUSDecrement by one, in either prefix or postfix position.NATIVEModifier for a method whose implementation lives outside the JVM.NEWIntroduces an instance creation, an array creation, or an anonymous class body.NULLThe null reference literal, and the last kind isLiteral accepts.PACKAGEIntroduces the package declaration at the head of a compilation unit.PERCENTRemainder of a division.PERCENT_EQReplaces the target with the remainder of dividing it.PIPEBitwise or non-short-circuiting logical OR, and the separator between the alternatives of a multi-catch clause.PIPE_EQBitwise or logical OR into the target.PIPE_PIPEConditional OR, which does not evaluate its right operand once the left is true.PLUSAddition, string concatenation, or unary plus.PLUS_EQAdds to the target in place; also the in-place string append.PLUS_PLUSIncrement by one, in either prefix or postfix position.PRIVATEAccess modifier limiting visibility to the declaring class.PROTECTEDAccess modifier granting visibility to subclasses and to the same package.PUBLICAccess modifier granting unrestricted visibility.QUESTIONThe condition separator of a conditional expression, and an unbounded wildcard type argument.RBRACECloses the construct opened by the matching LBRACE.RBRACKETCloses the construct opened by the matching LBRACKET.RETURNLeaves the enclosing method or constructor, with a value unless it is void.RPARENCloses the construct opened by the matching LPAREN.SEMICOLONTerminates a statement or declaration, and separates the clauses of a classic for loop.SHORTPrimitive type keyword for a signed 16-bit integer.SLASHDivision.SLASH_EQDivides the target in place.STARMultiplication, and the on-demand wildcard of an import.STAR_EQMultiplies the target in place.STATICModifier binding a member to the type rather than to an instance; also appears in static imports and in initializer blocks.STRICTFPModifier pinning floating point evaluation to strict IEEE 754 semantics.STRING_LITERALA quoted string or text block; the token also carries the decoded contents, with escapes resolved and text-block indentation stripped.SUPERRefers to the superclass - as a qualifier, as a constructor call, or as the lower bound of a wildcard.SWITCHIntroduces a switch statement or switch expression.SYNCHRONIZEDIntroduces a monitor-guarded block, or marks a method as guarded by its receiver's monitor.THISRefers to the current instance, and heads a delegating constructor call to the same class.THROWRaises an exception, unwinding until a handler matches.THROWSIntroduces the checked exception list of a method or constructor.TILDEBitwise complement.TRANSIENTModifier excluding a field from default serialization.TRUEThe true boolean literal, grouped with the literals rather than the keywords, so isLiteral accepts it and isKeyword does not.TRYIntroduces a try statement, with or without a resource list.VARRequests an inferred local variable type; the lexer treats it as a reserved word even though the language allows it as an identifier.VOIDMarks a method as producing no value, and names the void pseudo-type in a class literal.VOLATILEModifier making a field's reads and writes immediately visible across threads.WHILEIntroduces a while loop, and closes a do-while.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanisAssignmentOperator()booleanisComparisonOperator()booleanisKeyword()booleanisLiteral()booleanisModifier()booleanisPrimitiveType()static TokenTypevalueOf(String name)Returns the enum constant of this type with the specified name.static TokenType[]values()Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
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 nameNullPointerException- 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
-
-