mars.assembler
Class Token

java.lang.Object
  extended by mars.assembler.Token

public class Token
extends Object

Represents one token in the input MIPS program. Each Token carries, along with its type and value, the position (line, column) in which its source appears in the MIPS program.

Author:
Pete Sanderson

Constructor Summary
Token(TokenTypes type, String value, MIPSprogram sourceMIPSprogram, int line, int start)
          Constructor for Token class.
 
Method Summary
 int getSourceLine()
          Produces line number of MIPS program of this token.
 MIPSprogram getSourceMIPSprogram()
          Produces MIPSprogram object associated with this token.
 int getStartPos()
          Produces position within source line of this token.
 TokenTypes getType()
          Produces token type of this token.
 String getValue()
          Produces source code of this token.
 String toString()
          Get a String representing the token.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Token

public Token(TokenTypes type,
             String value,
             MIPSprogram sourceMIPSprogram,
             int line,
             int start)
Constructor for Token class.

Parameters:
type - The token type that this token has. (e.g. REGISTER_NAME)
value - The source value for this token (e.g. $t3)
sourceMIPSprogram - The MIPSprogram object containing this token
line - The line number in source program in which this token appears.
start - The starting position in that line number of this token's source value.
See Also:
TokenTypes
Method Detail

getType

public TokenTypes getType()
Produces token type of this token.

Returns:
TokenType of this token.

getValue

public String getValue()
Produces source code of this token.

Returns:
String containing source code of this token.

toString

public String toString()
Get a String representing the token. This method is equivalent to getValue().

Overrides:
toString in class Object
Returns:
String version of the token.

getSourceMIPSprogram

public MIPSprogram getSourceMIPSprogram()
Produces MIPSprogram object associated with this token.

Returns:
MIPSprogram object associated with this token.

getSourceLine

public int getSourceLine()
Produces line number of MIPS program of this token.

Returns:
line number in source program of this token.

getStartPos

public int getStartPos()
Produces position within source line of this token.

Returns:
first character position within source program line of this token.