simple.lexer
Class Token

java.lang.Object
  extended by 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

Nested Class Summary
static class Token.Type
           
 
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.
 
Method Summary
 Token.Type getType()
           
 java.lang.String getValue()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

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 type
value - 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
Method Detail

getType

public Token.Type getType()

getValue

public java.lang.String getValue()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object