Class Token

  • All Implemented Interfaces:
    TokenInterface

    public class Token
    extends java.lang.Object
    implements TokenInterface
    Token file contains the information needed for a token defined in the TokenType class. Token metadata includes tokentype, string lexeme of Identifier or Number, the line number of the token, and the column number of the token.
    • Constructor Detail

      • Token

        public Token​(TokenType type,
                     int line,
                     int column)
        Parameters:
        type - Type of token given in the TokenType class
        line - line number of the current token
        column - line number of the current token
      • Token

        public Token​(TokenType type,
                     int line,
                     int column,
                     java.lang.String lexeme)
        Parameters:
        type - Type of token given in the TokenType class
        line - line number of the current token
        column - starting column number of the current token
        lexeme - string representation of this token
    • Method Detail

      • getLexeme

        public java.lang.String getLexeme()
        Specified by:
        getLexeme in interface TokenInterface
        Returns:
        the string lexeme of this current token, empty if it's not an Identifier or a number.
      • getLineNumber

        public java.lang.String getLineNumber()
        Specified by:
        getLineNumber in interface TokenInterface
        Returns:
        the line number of this current token in string format.
      • getColumnNumber

        public java.lang.String getColumnNumber()
        Specified by:
        getColumnNumber in interface TokenInterface
        Returns:
        the column number of this current token in string format for string literals, the column number will be the ending of the string. (i.e. the second quotation)
      • toString

        public java.lang.String toString()
        Representation of the token in two format according to the use of constructor.
        Specified by:
        toString in interface TokenInterface
        Overrides:
        toString in class java.lang.Object
      • setAbsolutePath

        public void setAbsolutePath​(java.lang.String absolutePath)