Enum Class TokenKind

java.lang.Object
java.lang.Enum<TokenKind>
com.iizix.prop.gunit.internal.TokenKind
All Implemented Interfaces:
Serializable, Comparable<TokenKind>, Constable

public enum TokenKind extends Enum<TokenKind>
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
  • Enum Constant Details

    • NUMBER

      public static final TokenKind NUMBER
      A numeric literal: digits with an optional single decimal point. No sign, since a leading minus is a unary operator and compiles to a NEG opcode; and no exponent notation.
    • IDENT

      public static final TokenKind IDENT
      An identifier: a run of letters, OR a '%' followed by an optional run of letters. The second form is what makes %, %w, %h, %min and %max single tokens.
    • PLUS

      public static final TokenKind PLUS
      The '+' operator.
    • MINUS

      public static final TokenKind MINUS
      The '-' operator, binary subtraction or unary negation depending on position.
    • STAR

      public static final TokenKind STAR
      The '*' operator.
    • SLASH

      public static final TokenKind SLASH
      The '/' operator.
    • LPAREN

      public static final TokenKind LPAREN
      An opening parenthesis, whether a grouping one or a function call's.
    • RPAREN

      public static final TokenKind RPAREN
      A closing parenthesis.
    • COMMA

      public static final TokenKind COMMA
      An argument separator ',' inside a function call.
    • EOF

      public static final TokenKind EOF
      The end of the source. Its offset is the length of the source string and its length is zero.
  • Method Details

    • values

      public static TokenKind[] 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

      public static TokenKind valueOf(String name)
      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 name
      NullPointerException - if the argument is null