Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## mars.assembler
Class Token

    java.lang.Object
      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
`MIPSprogram` | `getOriginalProgram()` Produces original program containing this token.
`int` | `getOriginalSourceLine()` Produces original line number of this token.
`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.
`void` | `setOriginal(MIPSprogram origProgram, int origSourceLine)` Set original program and line number for this token.
`void` | `setType(TokenTypes type)` Set or modify token type.
`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

### setOriginal

    public void setOriginal(MIPSprogram origProgram,
                            int origSourceLine)

  Set original program and line number for this token. Line number or both may change during pre-assembly as a result of the ".include" directive, and we need to keep the original for later reference (error messages, text segment display).

  Parameters:
    `origProgram` - MIPS program containing this token.
    `origSourceLine` - Line within that program of this token.

### getOriginalProgram

    public MIPSprogram getOriginalProgram()

  Produces original program containing this token.

  Returns:
    MIPSprogram of origin for this token.

### getOriginalSourceLine

    public int getOriginalSourceLine()

  Produces original line number of this token. It could change as result of ".include"

  Returns:
    original line number of this token.

### getType

    public TokenTypes getType()

  Produces token type of this token.

  Returns:
    TokenType of this token.

### setType

    public void setType(TokenTypes type)

  Set or modify token type. Generally used to note that an identifier that matches an instruction name is actually being used as a label.

  Parameters:
    `type` - new TokenTypes for 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.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD