Enum Class TokenKind
- All Implemented Interfaces:
Serializable, Comparable<TokenKind>, Constable
The kinds of token produced by the
Lexer.The lexer deliberately does not distinguish a unit name from a function name: both arrive as IDENT and the Parser decides, because the decision depends on position. That keeps the lexer free of grammar knowledge and lets the parser produce a precise message such as "Unknown unit 'pxx' -- did you mean 'px'?" rather than a generic scan error.
- Author:
- Christopher Mindus
Nested Class Summary
Nested classes/interfaces inherited from class Enum
Enum.EnumDesc<E>Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionAn argument separator','inside a function call.The end of the source.An identifier: a run of letters, OR a'%'followed by an optional run of letters.An opening parenthesis, whether a grouping one or a function call's.The'-'operator, binary subtraction or unary negation depending on position.A numeric literal: digits with an optional single decimal point.The'+'operator.A closing parenthesis.The'/'operator.The'*'operator.Method Summary
Enum Constant Details
NUMBER
A numeric literal: digits with an optional single decimal point. No sign, since a leading minus is a unary operator and compiles to aNEGopcode; and no exponent notation.IDENT
An identifier: a run of letters, OR a'%'followed by an optional run of letters. The second form is what makes%,%w,%h,%minand%maxsingle tokens.PLUS
The'+'operator.MINUS
The'-'operator, binary subtraction or unary negation depending on position.STAR
The'*'operator.SLASH
The'/'operator.LPAREN
An opening parenthesis, whether a grouping one or a function call's.RPAREN
A closing parenthesis.COMMA
An argument separator','inside a function call.EOF
The end of the source. Its offset is the length of the source string and its length is zero.
Method Details
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (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 class has no constant with the specified nameNullPointerException- if the argument is null