|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectToken
public class Token
Each Token object represents one token from the compiler input stream.
Field Summary | |
---|---|
static int |
COLON
|
static int |
COMMA
|
static int |
DOT
|
static int |
EOF
|
static int |
ID
|
static int |
INTEGER
|
static int |
KW_CLASS
|
static int |
KW_ELSE
|
static int |
KW_IF
|
static int |
KW_INTEGER
|
static int |
KW_MOVIE
|
static int |
KW_PROLOG
|
static int |
KW_REAL
|
static int |
KW_SHOW
|
static int |
KW_STATIC
|
static int |
KW_VOID
|
private java.lang.String |
label
|
static int |
LCURLY
|
static int |
LPAREN
|
static int |
OP_ADD
|
static int |
OP_ASSIGN
|
static int |
OP_DIV
|
static int |
OP_EQ
|
static int |
OP_GT
|
static int |
OP_LT
|
static int |
OP_MUL
|
static int |
OP_NOT
|
static int |
OP_SUB
|
static int |
RCURLY
|
static int |
REAL
|
static int |
RPAREN
|
static int |
SEMICOLON
|
private static java.lang.String[] |
tokenTypes
The token types as Strings for use in toString. |
private int |
type
|
private java.lang.Number |
value
|
Constructor Summary | |
---|---|
Token(int t)
Construct a new Token with no attributes except its type. |
|
Token(int t,
double v)
Construct a new Token with an associated real value attribute. |
|
Token(int t,
int v)
Construct a new Token with an associated integer value attribute. |
|
Token(int t,
java.lang.String s)
Construct a new Token with an associated String attribute. |
Method Summary | |
---|---|
double |
getDoubleValue()
Get the numeric attribute of this token as a double value. |
int |
getIntValue()
Get the numeric attribute of this token as an int value. |
java.lang.String |
getLabel()
Get the String attribute of this object. |
int |
getType()
Get the type of this Token. |
java.lang.String |
toString()
Provide the String that describes this Token. |
static java.lang.String |
typeLabel(int type)
Provide the String that describes this Token type. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private int type
private java.lang.Number value
private java.lang.String label
private static java.lang.String[] tokenTypes
public static final int EOF
public static final int LPAREN
public static final int RPAREN
public static final int LCURLY
public static final int RCURLY
public static final int DOT
public static final int COMMA
public static final int SEMICOLON
public static final int COLON
public static final int ID
public static final int INTEGER
public static final int REAL
public static final int OP_ASSIGN
public static final int OP_NOT
public static final int OP_EQ
public static final int OP_LT
public static final int OP_GT
public static final int OP_ADD
public static final int OP_SUB
public static final int OP_MUL
public static final int OP_DIV
public static final int KW_STATIC
public static final int KW_VOID
public static final int KW_INTEGER
public static final int KW_REAL
public static final int KW_IF
public static final int KW_ELSE
public static final int KW_PROLOG
public static final int KW_MOVIE
public static final int KW_CLASS
public static final int KW_SHOW
Constructor Detail |
---|
public Token(int t)
t
- the token type, one of the types defined by the Token class.public Token(int t, java.lang.String s)
t
- the token type (probably Token.ID).s
- the value of the String attribute for this tokenpublic Token(int t, int v)
t
- the token type (probably Token.INTEGER).v
- the integer value of the numeric attribute for this tokenpublic Token(int t, double v)
t
- the token type (probably Token.REAL).v
- the double value of the numeric attribute for this tokenMethod Detail |
---|
public int getType()
public java.lang.String getLabel()
public int getIntValue()
public double getDoubleValue()
public java.lang.String toString()
toString
in class java.lang.Object
public static java.lang.String typeLabel(int type)
type
- the Token type to be described. Must be a valid
(defined) Token type, or a runtime Exception will occur.
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |