Enum Class TokenKind

java.lang.Object
java.lang.Enum<TokenKind>
team.unnamed.mocha.lexer.TokenKind
All Implemented Interfaces:
Serializable, Comparable<TokenKind>, Constable

public enum TokenKind extends Enum<TokenKind>
An enum of token kinds. Represents a single token kind.

Tokens are, commonly, a sequence of one or more continuous characters, like "??", "->", "!", "true", "1.0", "2.0", ...

Tokens do not have an specific behavior, they just group certain characters that can be used by the parser.

Since:
3.0.0
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    An enum of tags for token kinds.

    Nested classes/interfaces inherited from class java.lang.Enum

    Enum.EnumDesc<E extends Enum<E>>
  • Enum Constant Summary

    Enum Constants
    Enum Constant
    Description
    Double ampersand token (&&)
    Arrow token (->)
    The bang or exclamation symbol (!)
    Bang-eq token (!=)
    Double bar token (||)
    The "break" keyword
    Colon symbol (:)
    Comma symbol (,)
    The "continue" keyword
    The dot symbol (.)
    End-of-file token, means that the end was reached
    Equal symbol (=)
    Equal-equal token (==)
    Error token, means that there was an error there
    'False' literal boolean token
    Float literal token, has a string value of its content, which can be parsed to a floating-point number
    Greater-than token (>)
    Greater-than-or-equal token (>=)
    Identifier token, has a string value of the identifier name
    Left-brace symbol "{"
    Left-bracket token "["
    Left-parenthesis symbol "("
    Less-than token (<)
    Less-than-or-equal token (<=)
    Plus symbol (+)
    Question symbol (?)
    Question-question token (??)
    Right-brace symbol "}"
    Right-bracket "]
    The "return" keyword
    Right-parenthesis symbol ")"
    Semicolon symbol (;)
    Slash symbol (/)
    Star symbol (*)
    String literal token, has a string value of its content
    Hyphen/sub symbol (-)
    'True' literal boolean token
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    hasTag(@NotNull TokenKind.Tag tag)
    Determines if this token kind has a certain tag.
    static TokenKind
    Returns the enum constant of this class with the specified name.
    static TokenKind[]
    Returns an array containing the constants of this enum class, in the order they are declared.

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Enum Constant Details

    • EOF

      public static final TokenKind EOF
      End-of-file token, means that the end was reached
    • ERROR

      public static final TokenKind ERROR
      Error token, means that there was an error there
    • IDENTIFIER

      public static final TokenKind IDENTIFIER
      Identifier token, has a string value of the identifier name
    • STRING

      public static final TokenKind STRING
      String literal token, has a string value of its content
    • FLOAT

      public static final TokenKind FLOAT
      Float literal token, has a string value of its content, which can be parsed to a floating-point number
    • TRUE

      public static final TokenKind TRUE
      'True' literal boolean token
    • FALSE

      public static final TokenKind FALSE
      'False' literal boolean token
    • BREAK

      public static final TokenKind BREAK
      The "break" keyword
    • CONTINUE

      public static final TokenKind CONTINUE
      The "continue" keyword
    • RETURN

      public static final TokenKind RETURN
      The "return" keyword
    • DOT

      public static final TokenKind DOT
      The dot symbol (.)
    • BANG

      public static final TokenKind BANG
      The bang or exclamation symbol (!)
    • AMPAMP

      public static final TokenKind AMPAMP
      Double ampersand token (&&)
    • BARBAR

      public static final TokenKind BARBAR
      Double bar token (||)
    • LT

      public static final TokenKind LT
      Less-than token (<)
    • LTE

      public static final TokenKind LTE
      Less-than-or-equal token (<=)
    • GT

      public static final TokenKind GT
      Greater-than token (>)
    • GTE

      public static final TokenKind GTE
      Greater-than-or-equal token (>=)
    • EQ

      public static final TokenKind EQ
      Equal symbol (=)
    • EQEQ

      public static final TokenKind EQEQ
      Equal-equal token (==)
    • BANGEQ

      public static final TokenKind BANGEQ
      Bang-eq token (!=)
    • STAR

      public static final TokenKind STAR
      Star symbol (*)
    • SLASH

      public static final TokenKind SLASH
      Slash symbol (/)
    • PLUS

      public static final TokenKind PLUS
      Plus symbol (+)
    • SUB

      public static final TokenKind SUB
      Hyphen/sub symbol (-)
    • LPAREN

      public static final TokenKind LPAREN
      Left-parenthesis symbol "("
    • RPAREN

      public static final TokenKind RPAREN
      Right-parenthesis symbol ")"
    • LBRACE

      public static final TokenKind LBRACE
      Left-brace symbol "{"
    • RBRACE

      public static final TokenKind RBRACE
      Right-brace symbol "}"
    • QUESQUES

      public static final TokenKind QUESQUES
      Question-question token (??)
    • QUES

      public static final TokenKind QUES
      Question symbol (?)
    • COLON

      public static final TokenKind COLON
      Colon symbol (:)
    • ARROW

      public static final TokenKind ARROW
      Arrow token (->)
    • LBRACKET

      public static final TokenKind LBRACKET
      Left-bracket token "["
    • RBRACKET

      public static final TokenKind RBRACKET
      Right-bracket "]
    • COMMA

      public static final TokenKind COMMA
      Comma symbol (,)
    • SEMICOLON

      public static final TokenKind SEMICOLON
      Semicolon symbol (;)
  • 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
    • hasTag

      public boolean hasTag(@NotNull @NotNull TokenKind.Tag tag)
      Determines if this token kind has a certain tag.
      Parameters:
      tag - The tag to check.
      Returns:
      True if this token kind is tagged with the given tag
      Since:
      3.0.0