Interface Token

All Known Implementing Classes:
AntlrLexicalAnalyzer.EmuToken, SourceToken

public interface Token
Interface that identifies a token.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
     
    static final int
    Opening and closing tokens of a foldable source block.
    static final int
    Token is a comment.
    static final int
    Token represents end-of-file.
    static final int
    Token is of unknown type.
    static final int
    Token is an identifier (e.g.
    static final int
    A token naming another source file.
    static final int
    Token is an label identifier.
    static final int
    Token is a literal (e.g.
    static final int
    Token is a operator (e.g.
    static final int
    Token is a preprocessor keyword.
    static final int
    Token is a CPU register.
    static final int
    Token is a reserved word.
    static final int
    Token is a separator (e.g.
    static final int
    A symbol declaration identified by source analysis.
    static final int
    Token is a whitespace
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Get 0-based starting offset in UTF-16 code units (Java String indices).
    default String
    Referenced source file path, or null when the token is not an include path.
    default String
    Symbol spelling, excluding punctuation, or null when this token has no symbol metadata.
    Get token value.
    int
    Get token type.
  • Field Details

    • RESERVED

      static final int RESERVED
      Token is a reserved word.
      See Also:
    • PREPROCESSOR

      static final int PREPROCESSOR
      Token is a preprocessor keyword.
      See Also:
    • REGISTER

      static final int REGISTER
      Token is a CPU register.
      See Also:
    • SEPARATOR

      static final int SEPARATOR
      Token is a separator (e.g. ' ', tab, '\n', ...).
      See Also:
    • OPERATOR

      static final int OPERATOR
      Token is a operator (e.g. +, -, *, /, ...).
      See Also:
    • COMMENT

      static final int COMMENT
      Token is a comment. Most assemblers used semicolon (";") as start of a comment.
      See Also:
    • LITERAL

      static final int LITERAL
      Token is a literal (e.g. number, string, char, ...).
      See Also:
    • IDENTIFIER

      static final int IDENTIFIER
      Token is an identifier (e.g. name of variable, name of macro...).
      See Also:
    • LABEL

      static final int LABEL
      Token is an label identifier.
      See Also:
    • BLOCK_START

      static final int BLOCK_START
      Opening and closing tokens of a foldable source block.
      See Also:
    • BLOCK_END

      static final int BLOCK_END
      See Also:
    • SYMBOL_DEFINITION

      static final int SYMBOL_DEFINITION
      A symbol declaration identified by source analysis.
      See Also:
    • INCLUDE_PATH

      static final int INCLUDE_PATH
      A token naming another source file.
      See Also:
    • WHITESPACE

      static final int WHITESPACE
      Token is a whitespace
      See Also:
    • ERROR

      static final int ERROR
      Token is of unknown type.
      See Also:
    • EOF

      static final int EOF
      Token represents end-of-file. This token should be the last found token.
      See Also:
  • Method Details

    • getReferencedFile

      default String getReferencedFile()
      Referenced source file path, or null when the token is not an include path.
    • getSymbolName

      default String getSymbolName()
      Symbol spelling, excluding punctuation, or null when this token has no symbol metadata.
    • getType

      int getType()
      Get token type.

      The token type mus be one of the pre-defined constants located inside this interface (e.g. RESERVED, PREPROCESSOR, etc.).

      Returns:
      type of the token
    • getOffset

      int getOffset()
      Get 0-based starting offset in UTF-16 code units (Java String indices).
      Returns:
      starting offset of the token in the source code
    • getText

      String getText()
      Get token value.
      Returns:
      token value