Module hw06

Class Token

java.lang.Object
provided.tokenFW.Token

public class Token extends Object
Represents a token in the language.
  • Field Details

    • _name

      String _name
      The name of this token, which is its id.
    • _lexeme

      private String _lexeme
      The _lexeme (lexical value) this token is representing.
  • Constructor Details

    • Token

      public Token(String name, String lexeme)
      Token constructor.
      Parameters:
      name - The name associated with this token. This is the id value when it executes its visitors.
      lexeme - _lexeme this token is representing.
  • Method Details

    • execute

      public Object execute(ITokVisitor algo, Object... params)
      Executes (accepts) the visitor, calling the case associated with this host's name value.
      Parameters:
      algo - The visitor to execute
      params - The input parameters supplied to the algo when its appropriate case is called.
      Returns:
      The return value from executing the appropriate case on the visitor.
    • getName

      public String getName()
      Accessor for the name of this token
      Returns:
      The name of this token
    • getLexeme

      public String getLexeme()
      Accessor for the lexeme of this token
      Returns:
      The lexeme of this token
    • toString

      public String toString()
      Return a string representation of the token: "[name] lexeme"
      Overrides:
      toString in class Object
      Returns:
      string representation