package rebelsky.compiler.lexer; import rebelsky.compiler.misc.Symbol; /** * Tokens for a generic tokenizer/lexer/whatever. * * @author Samuel A. Rebelsky * @version 1.0 of October 2002 */ public class Token implements Symbol { // +--------+------------------------------------------------------------ // | Fields | // +--------+ /** The type of the token. */ int tokType; // +--------------+------------------------------------------------------ // | Constructors | // +--------------+ /** * Create a new token of a specified type. */ public Token(int type) { this.tokType = type; } // Token(int) // +-----------+--------------------------------------------------------- // | Observers | // +-----------+ /** * Determine if the token is the same as another token. Should * probably be overridden by subclasses. */ public boolean equals(Token other) { return this == other; } // equals(Token) /** * Get the type of the token. */ public int getType() { return this.tokType; } // getType(void) /** * Convert the token to a string (e.g., for printing). Should * probably be overridden by subclasses. */ public String toString() { return "Token[" + this.tokType + "]"; } // toString(void) } // class Token