Interface Token.Type

Enclosing class:
Token<V>

public static interface Token.Type
Represents the type of the token, with a given type code and type name.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Token.Type
    The common end of file token type.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Return the type code, which uniquely identifies the token type.
    Return the name of the token.
    static <V> Token.Type
    of(int code, String name)
    Create a new token type with the given code and name.
    default Token<String>
    token(char c)
    Create a new token of the given character and this type.
    default <V> Token<V>
    token(V value)
    Create a new token of the given value and this type.
  • Field Details

    • EOF

      static final Token.Type EOF
      The common end of file token type.
  • Method Details

    • code

      int code()
      Return the type code, which uniquely identifies the token type.
      Returns:
      the code of the token type
    • name

      Return the name of the token.
      Returns:
      the name of the token
    • token

      default <V> Token<V> token(V value)
      Create a new token of the given value and this type.
      Parameters:
      value - the token value
      Returns:
      a new toke
      Throws:
      NullPointerException - if the given value is null
    • token

      default Token<String> token(char c)
      Create a new token of the given character and this type.
      Parameters:
      c - the token value
      Returns:
      a new toke
    • of

      static <V> Token.Type of(int code, String name)
      Create a new token type with the given code and name.
      Parameters:
      code - the code of the created token type
      name - the name of the created token type
      Returns:
      a new token type
      Throws:
      NullPointerException - if the given name is null