simple.lexer
Class Token
java.lang.Object
simple.lexer.Token
public class Token
- extends java.lang.Object
A Token
represents a lexical token outputted by Lexer
.
It has a type (Token.Type
) and a value (String
).
- Author:
- Santoso Wijaya
Constructor Summary |
protected |
Token(Token.Type type)
Creates a token of the given type. |
protected |
Token(Token.Type type,
java.lang.String value)
Creates a token of given type and value. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Token
protected Token(Token.Type type,
java.lang.String value)
- Creates a token of given type and value. The given value is only
used if the given type does not have a static value (e.g.
NUMBER
).
- Parameters:
type
- the token typevalue
- the token value, if type does not define it
Token
protected Token(Token.Type type)
- Creates a token of the given type. Ideally used for types that define
static values. Otherwise, an empty string is given to this token's
value.
- Parameters:
type
- the token type
getType
public Token.Type getType()
getValue
public java.lang.String getValue()
toString
public java.lang.String toString()
- Overrides:
toString
in class java.lang.Object