// Token class

// Date: 3/1/98
// Author: Adam Berger
// Description: class storing a single instance of a token 

import java.math.*;

public class Token implements TokenTypes {

  public Token() {};
  public Token(int t) { type=t; }
  public Token(int t, String lexeme) {
    type=t;
    if (type==T_NUMBER) { value=new BigInteger(lexeme); }
    if (type==T_IDENT) spelling=lexeme; 
    // if the token isn't a number, retain the value
    // if it's an identifer, retain the spelling
    // if it's neither, then 'type' contains all the info we need
  }

  public boolean isEOF()       { return (type==T_EOF); } 
  public int getType()         { return type; } 
  public BigInteger getValue() { return value; }
  public String getLexeme()    { return spelling; }
  
  public void show() { 
    if (type==T_IDENT) System.out.println("Identifier ("+spelling+")");
    else if (type==T_NUMBER) System.out.println("Number ("+value.toString()+")");
    else System.out.println(reservedLexemes[type]);
  }

  private int type;         // one of the types enumerated in TokenTypes
  private BigInteger value; // only applicable for a number 
  private String spelling;  // only applicable for an identifier
}
