mars.assembler
Class TokenTypes

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

public final class TokenTypes
extends Object

Constants to identify the types of tokens found in MIPS programs. If Java had enumerated types, that's how these would probably be implemented.

Author:
Pete Sanderson

Field Summary
static TokenTypes COLON
           
static TokenTypes COMMENT
           
static TokenTypes DELIMITER
           
static TokenTypes DIRECTIVE
           
static TokenTypes ERROR
           
static TokenTypes FP_REGISTER_NAME
           
static TokenTypes IDENTIFIER
           
static TokenTypes INTEGER_16
           
static TokenTypes INTEGER_16U
           
static TokenTypes INTEGER_32
           
static TokenTypes INTEGER_5
           
static TokenTypes LEFT_PAREN
           
static TokenTypes MACRO_PARAMETER
           
static TokenTypes MINUS
           
static TokenTypes OPERATOR
           
static TokenTypes PLUS
           
static TokenTypes QUOTED_STRING
           
static TokenTypes REAL_NUMBER
           
static TokenTypes REGISTER_NAME
          note: REGISTER_NAME is token of form $zero whereas REGISTER_NUMBER is token of form $0.
static TokenTypes REGISTER_NUMBER
           
static TokenTypes RIGHT_PAREN
           
static String TOKEN_DELIMITERS
           
 
Method Summary
static boolean isFloatingTokenType(TokenTypes type)
          Lets you know if given tokentype is for floating point numbers (REAL_NUMBER).
static boolean isIntegerTokenType(TokenTypes type)
          Lets you know if given tokentype is for integers (INTGER_5, INTEGER_16, INTEGER_32).
static boolean isValidIdentifier(String value)
           
static TokenTypes matchTokenType(String value)
          Classifies the given token into one of the MIPS types.
 String toString()
          Produces String equivalent of this token type, which is its name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TOKEN_DELIMITERS

public static final String TOKEN_DELIMITERS
See Also:
Constant Field Values

COMMENT

public static final TokenTypes COMMENT

DIRECTIVE

public static final TokenTypes DIRECTIVE

OPERATOR

public static final TokenTypes OPERATOR

DELIMITER

public static final TokenTypes DELIMITER

REGISTER_NAME

public static final TokenTypes REGISTER_NAME
note: REGISTER_NAME is token of form $zero whereas REGISTER_NUMBER is token of form $0. The former is part of extended assembler, and latter is part of basic assembler.


REGISTER_NUMBER

public static final TokenTypes REGISTER_NUMBER

FP_REGISTER_NAME

public static final TokenTypes FP_REGISTER_NAME

IDENTIFIER

public static final TokenTypes IDENTIFIER

LEFT_PAREN

public static final TokenTypes LEFT_PAREN

RIGHT_PAREN

public static final TokenTypes RIGHT_PAREN

INTEGER_5

public static final TokenTypes INTEGER_5

INTEGER_16

public static final TokenTypes INTEGER_16

INTEGER_16U

public static final TokenTypes INTEGER_16U

INTEGER_32

public static final TokenTypes INTEGER_32

REAL_NUMBER

public static final TokenTypes REAL_NUMBER

QUOTED_STRING

public static final TokenTypes QUOTED_STRING

PLUS

public static final TokenTypes PLUS

MINUS

public static final TokenTypes MINUS

COLON

public static final TokenTypes COLON

ERROR

public static final TokenTypes ERROR

MACRO_PARAMETER

public static final TokenTypes MACRO_PARAMETER
Method Detail

toString

public String toString()
Produces String equivalent of this token type, which is its name.

Overrides:
toString in class Object
Returns:
String containing descriptive name for token type.

matchTokenType

public static TokenTypes matchTokenType(String value)
Classifies the given token into one of the MIPS types.

Parameters:
value - String containing candidate language element, extracted from MIPS program.
Returns:
Returns the corresponding TokenTypes object if the parameter matches a defined MIPS token type, else returns null.

isIntegerTokenType

public static boolean isIntegerTokenType(TokenTypes type)
Lets you know if given tokentype is for integers (INTGER_5, INTEGER_16, INTEGER_32).

Parameters:
type - the TokenType of interest
Returns:
true if type is an integer type, false otherwise.

isFloatingTokenType

public static boolean isFloatingTokenType(TokenTypes type)
Lets you know if given tokentype is for floating point numbers (REAL_NUMBER).

Parameters:
type - the TokenType of interest
Returns:
true if type is an floating point type, false otherwise.

isValidIdentifier

public static boolean isValidIdentifier(String value)