Enum Class TokenType

java.lang.Object
java.lang.Enum<TokenType>
mars.assembler.token.TokenType
All Implemented Interfaces:
Serializable, Comparable<TokenType>, Constable

public enum TokenType extends Enum<TokenType>
Enumeration to identify the types of tokens found in MIPS programs.
Version:
August 2003
Author:
Pete Sanderson
  • Nested Class Summary

    Nested classes/interfaces inherited from class java.lang.Enum

    Enum.EnumDesc<E extends Enum<E>>
  • Enum Constant Summary

    Enum Constants
    Enum Constant
    Description
    A token representing a character literal.
    A token representing a colon (i.e.
    A token representing an end-of-line comment starting with #.
    A token representing a visible operand delimiter (i.e. comma).
    A token representing either a preprocessor directive (e.g.
    A token that is malformed and could not be tokenized properly.
    A token representing a Coprocessor 1 (FPU) register referenced by name (e.g.
    A token representing an identifier (e.g.
    A token representing an unsigned integer which can fit in 15 bits.
    A token representing a signed integer which can fit in 16 bits.
    A token representing an unsigned integer which can fit in 16 bits.
    A token representing an unsigned integer which can fit in 3 bits.
    A token representing a 32-bit integer, signed or unsigned.
    A token representing an unsigned integer which can fit in 5 bits.
    A token representing a left parenthesis (i.e.
    A token representing a macro parameter starting with % or $ (e.g.
    A token representing a minus (i.e.
    A token representing the mnemonic of an instruction (e.g.
    A token representing a plus (i.e.
    A token representing a double-precision floating-point number.
    A token representing a CPU register referenced by name (e.g.
    A token representing a CPU or Coprocessor 0 register referenced by number (e.g.
    A token representing a right parenthesis (i.e.
    A token representing a string literal.
    A token representing a template substitution wrapped in curly braces.
  • Method Summary

    Modifier and Type
    Method
    Description
    static TokenType
    fromIntegerValue(int value)
    Determine the smallest integer TokenType which fits the given value, taking signedness into account.
    boolean
     
    boolean
    Determine whether this token type is a floating-point number (i.e.
    boolean
    Determine whether this token type is an integer (i.e.
    static TokenType
    Returns the enum constant of this class with the specified name.
    static TokenType[]
    Returns an array containing the constants of this enum class, in the order they are declared.

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Enum Constant Details

    • ERROR

      public static final TokenType ERROR
      A token that is malformed and could not be tokenized properly. This is used primarily for syntax highlighting. The corresponding token value is null.
    • DELIMITER

      public static final TokenType DELIMITER
      A token representing a visible operand delimiter (i.e. comma). This is used primarily for syntax highlighting. The corresponding token value is null.
    • COMMENT

      public static final TokenType COMMENT
      A token representing an end-of-line comment starting with #. This is used primarily for syntax highlighting. The corresponding token value is null.
    • DIRECTIVE

      public static final TokenType DIRECTIVE
      A token representing either a preprocessor directive (e.g. .include) or an assembler directive (e.g. .text). The corresponding token value is the variant of Directive corresponding to the literal.
    • OPERATOR

      public static final TokenType OPERATOR
      A token representing the mnemonic of an instruction (e.g. lui). The corresponding token value is a List of the Instructions with that mnemonic.
    • REGISTER_NUMBER

      public static final TokenType REGISTER_NUMBER
      A token representing a CPU or Coprocessor 0 register referenced by number (e.g. $0). The corresponding token value is the register number as an Integer.
    • REGISTER_NAME

      public static final TokenType REGISTER_NAME
      A token representing a CPU register referenced by name (e.g. $zero). The corresponding token value is the register number as an Integer.
    • FP_REGISTER_NAME

      public static final TokenType FP_REGISTER_NAME
      A token representing a Coprocessor 1 (FPU) register referenced by name (e.g. $f0). The corresponding token value is the register number as an Integer.
    • IDENTIFIER

      public static final TokenType IDENTIFIER
      A token representing an identifier (e.g. label). The corresponding token value is null.
    • INTEGER_3_UNSIGNED

      public static final TokenType INTEGER_3_UNSIGNED
      A token representing an unsigned integer which can fit in 3 bits. The corresponding token value is the numeric value, zero-extended, as an Integer.
    • INTEGER_5_UNSIGNED

      public static final TokenType INTEGER_5_UNSIGNED
      A token representing an unsigned integer which can fit in 5 bits. The corresponding token value is the numeric value, zero-extended, as an Integer.
    • INTEGER_15_UNSIGNED

      public static final TokenType INTEGER_15_UNSIGNED
      A token representing an unsigned integer which can fit in 15 bits. The purpose of this type is to identify integers that fit within the ranges of both signed and unsigned 16-bit integers. The corresponding token value is the numeric value, zero-extended, as an Integer.
    • INTEGER_16_SIGNED

      public static final TokenType INTEGER_16_SIGNED
      A token representing a signed integer which can fit in 16 bits. The corresponding token value is the numeric value, sign-extended, as an Integer.
    • INTEGER_16_UNSIGNED

      public static final TokenType INTEGER_16_UNSIGNED
      A token representing an unsigned integer which can fit in 16 bits. The corresponding token value is the numeric value, zero-extended, as an Integer.
    • INTEGER_32

      public static final TokenType INTEGER_32
      A token representing a 32-bit integer, signed or unsigned. The corresponding token value is the numeric value as an Integer.
    • REAL_NUMBER

      public static final TokenType REAL_NUMBER
      A token representing a double-precision floating-point number. The corresponding token value is the numeric value as a Double.
    • CHARACTER

      public static final TokenType CHARACTER
      A token representing a character literal. The corresponding token value is the numeric value as an Integer.
    • STRING

      public static final TokenType STRING
      A token representing a string literal. The corresponding token value is the value of the string as a String.
    • PLUS

      public static final TokenType PLUS
      A token representing a plus (i.e. +). The corresponding token value is null.
    • MINUS

      public static final TokenType MINUS
      A token representing a minus (i.e. -). The corresponding token value is null.
    • COLON

      public static final TokenType COLON
      A token representing a colon (i.e. :). The corresponding token value is null.
    • LEFT_PAREN

      public static final TokenType LEFT_PAREN
      A token representing a left parenthesis (i.e. (). The corresponding token value is null.
    • RIGHT_PAREN

      public static final TokenType RIGHT_PAREN
      A token representing a right parenthesis (i.e. )). The corresponding token value is null.
    • MACRO_PARAMETER

      public static final TokenType MACRO_PARAMETER
      A token representing a macro parameter starting with % or $ (e.g. %arg). The corresponding token value is null.
    • TEMPLATE_SUBSTITUTION

      public static final TokenType TEMPLATE_SUBSTITUTION
      A token representing a template substitution wrapped in curly braces. The corresponding token value is a List of the Tokens contained within the curly braces.
  • Method Details

    • values

      public static TokenType[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static TokenType valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • isInteger

      public boolean isInteger()
      Determine whether this token type is an integer (i.e. INTEGER_3_UNSIGNED, INTEGER_5_UNSIGNED, INTEGER_15_UNSIGNED INTEGER_16_SIGNED, INTEGER_16_UNSIGNED, or INTEGER_32).
      Returns:
      true if this is an integer type, or false otherwise.
    • isFloatingPoint

      public boolean isFloatingPoint()
      Determine whether this token type is a floating-point number (i.e. REAL_NUMBER).
      Returns:
      true if this is a floating-point type, or false otherwise.
    • isDirectiveContinuation

      public boolean isDirectiveContinuation()
    • fromIntegerValue

      public static TokenType fromIntegerValue(int value)
      Determine the smallest integer TokenType which fits the given value, taking signedness into account.
      Parameters:
      value - The value to determine the type of.
      Returns:
      The narrowest possible integer type.