geneseo.cs.compiler
Class Token

java.lang.Object
  |
  +--geneseo.cs.compiler.Token
Direct Known Subclasses:
MinimLToken

public abstract class Token
extends java.lang.Object

Represents tokens produced by lexical analyzers. Potentially, any lexical analyzer can use subclasses of this class to represent its tokens.


Constructor Summary
Token()
           
 
Method Summary
 java.lang.Object auxData()
          Retrieve any auxiliary data associated with a token.
 java.lang.String toString()
          Generate a string representation of a token.
abstract  int type()
          Return an integer code for a token's type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Token

public Token()
Method Detail

type

public abstract int type()
Return an integer code for a token's type. Type codes will be application-specific, and so have to be defined by subclasses.
Returns:
The type code.

auxData

public java.lang.Object auxData()
Retrieve any auxiliary data associated with a token. This may be such data as the name of an identifier, the value of a number, etc. The exact type of data will generally depend on what the token represents. By default, a token's auxiliary data is null.
Returns:
The auxiliary data, or null if there is no auxiliary data associated with this token.

toString

public java.lang.String toString()
Generate a string representation of a token. By default, the string simply identifies the object as a token, and displays its type. Subclasses can, and generally should, override this behavior.
Overrides:
toString in class java.lang.Object
Returns:
The string describing the token.