Interface Token


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

      Fields 
      Modifier and Type Field Description
      static int COMMENT
      Token is a comment.
      static int ERROR
      Token is of unknown type.
      static int IDENTIFIER
      Token is an identifier (e.g.
      static int LABEL
      Token is an label identifier.
      static int LITERAL
      Token is a literal (e.g.
      static int OPERATOR
      Token is a operator (e.g.
      static int PREPROCESSOR
      Token is a preprocessor keyword.
      static int REGISTER
      Token is a CPU register.
      static int RESERVED
      Token is a reserved word.
      static int SEPARATOR
      Token is a separator (e.g.
      static int TEOF
      Token represents end-of-file.
    • Field Detail

      • PREPROCESSOR

        static final int PREPROCESSOR
        Token is a preprocessor keyword.
        See Also:
        Constant Field Values
      • SEPARATOR

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

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

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

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

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

        static final int TEOF
        Token represents end-of-file. This token should be the last found token.
        See Also:
        Constant Field Values
    • Method Detail

      • getID

        int getID()
        Get token ID.

        The token ID is compiler-specific value. Each token must have unique ID.

        Returns:
        ID of the token
      • 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
      • getLine

        int getLine()
        Get 0-based starting line (row) of token position.
        Returns:
        start line number of the token
      • getColumn

        int getColumn()
        Get 0-based starting column of token position.
        Returns:
        start column number of the token
      • getOffset

        int getOffset()
        Get 0-based starting offset of token position.
        Returns:
        starting offset of the token in the source code
      • getLength

        int getLength()
        Get length of the token.
        Returns:
        length of the token
      • getErrorString

        java.lang.String getErrorString()
        Get error string for this token.

        If the token is not errorneous, return empty string ("").

        Returns:
        error string message for this token
      • getText

        java.lang.String getText()
        Get token value.
        Returns:
        token value
      • getLexerState

        int getLexerState()
        Get lexer state
        Returns:
        lexer state of this token