Class Lexer.Token

  • Enclosing class:
    Lexer

    static class Lexer.Token
    extends java.lang.Object
    This class holds the information about lexemes in the input stream.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      (package private) static class  Lexer.Token.Type
      Valid token types.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) java.lang.String lexeme
      The lexeme of this token.
      (package private) int position
      The position of this token.
      (package private) Lexer.Token.Type type
      The type of this token.
    • Constructor Summary

      Constructors 
      Constructor Description
      Token​(Lexer.Token.Type type, java.lang.String lexeme, int position)
      Constructs a Token instance with the type, lexeme and position.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object other)
      int hashCode()
      java.lang.String toString()
      Returns the string representation of this token.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • lexeme

        final java.lang.String lexeme
        The lexeme of this token.
      • position

        final int position
        The position of this token.
    • Constructor Detail

      • Token

        Token​(Lexer.Token.Type type,
              java.lang.String lexeme,
              int position)
        Constructs a Token instance with the type, lexeme and position.
        Parameters:
        type - the type of this token
        lexeme - the lexeme of this token
        position - the position of this token
    • Method Detail

      • equals

        public boolean equals​(java.lang.Object other)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Returns the string representation of this token.
        Overrides:
        toString in class java.lang.Object
        Returns:
        the string representation of this token