Class TokenTypes

java.lang.Object
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.
Version:
August 2003
Author:
Pete Sanderson
  • Field Details

    • 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 Details

    • 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)