Package mars.assembler.token
Enum Class TokenType
- All Implemented Interfaces:
Serializable
,Comparable<TokenType>
,Constable
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 ConstantsEnum ConstantDescriptionA 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 TypeMethodDescriptionstatic TokenType
fromIntegerValue
(int value) Determine the smallest integerTokenType
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[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
ERROR
A token that is malformed and could not be tokenized properly. This is used primarily for syntax highlighting. The corresponding token value isnull
. -
DELIMITER
A token representing a visible operand delimiter (i.e. comma). This is used primarily for syntax highlighting. The corresponding token value isnull
. -
COMMENT
A token representing an end-of-line comment starting with#
. This is used primarily for syntax highlighting. The corresponding token value isnull
. -
DIRECTIVE
-
OPERATOR
A token representing the mnemonic of an instruction (e.g.lui
). The corresponding token value is aList
of theInstruction
s with that mnemonic. -
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 anInteger
. -
REGISTER_NAME
A token representing a CPU register referenced by name (e.g.$zero
). The corresponding token value is the register number as anInteger
. -
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 anInteger
. -
IDENTIFIER
A token representing an identifier (e.g.label
). The corresponding token value isnull
. -
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 anInteger
. -
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 anInteger
. -
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 anInteger
. -
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 anInteger
. -
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 anInteger
. -
INTEGER_32
A token representing a 32-bit integer, signed or unsigned. The corresponding token value is the numeric value as anInteger
. -
REAL_NUMBER
A token representing a double-precision floating-point number. The corresponding token value is the numeric value as aDouble
. -
CHARACTER
A token representing a character literal. The corresponding token value is the numeric value as anInteger
. -
STRING
A token representing a string literal. The corresponding token value is the value of the string as aString
. -
PLUS
A token representing a plus (i.e.+
). The corresponding token value isnull
. -
MINUS
A token representing a minus (i.e.-
). The corresponding token value isnull
. -
COLON
A token representing a colon (i.e.:
). The corresponding token value isnull
. -
LEFT_PAREN
A token representing a left parenthesis (i.e.(
). The corresponding token value isnull
. -
RIGHT_PAREN
A token representing a right parenthesis (i.e.)
). The corresponding token value isnull
. -
MACRO_PARAMETER
A token representing a macro parameter starting with%
or$
(e.g.%arg
). The corresponding token value isnull
. -
TEMPLATE_SUBSTITUTION
-
-
Method Details
-
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
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 nameNullPointerException
- 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
, orINTEGER_32
).- Returns:
true
if this is an integer type, orfalse
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, orfalse
otherwise.
-
isDirectiveContinuation
public boolean isDirectiveContinuation() -
fromIntegerValue
Determine the smallest integerTokenType
which fits the given value, taking signedness into account.- Parameters:
value
- The value to determine the type of.- Returns:
- The narrowest possible integer type.
-