/**
   Class Token describes a lexical entity in the input.  The following
   Token types are recognized:
   <ul>
   <li>
   Identifier: a word consisting of letters and digits.  The first
   character must be a letter.
   </li>
   <li>
   String: a character string delimited by double quotes " ". Note
   that the length of the string may be zero.
   </li>
   <li>
   Left parenthesis '('.
   </li>
   <li>
   Right parenthesis ')'.
   </li>
   <li>
   Comma ','.
   </li>
   <li>
   Semicolon ';'.
   </li>
   <li>
   Assignment '='.
   </li>
   </ul>
 */
public class Token {
    /** Identifier Token type. */
    public static final int IDENTIFIER	= 0;
    /** String Token type. */
    public static final int STRING	= 1;
    /** Left parenthesis Token type. */
    public static final int LEFT_PAREN	= 2;
    /** Right parenthesis Token type. */
    public static final int RIGHT_PAREN	= 3;
    /** Comma Token type. */
    public static final int COMMA	= 4;
    /** Semicolon Token type. */
    public static final int SEMICOLON	= 5;
    /** Assignment Token type. */
    public static final int ASSIGN	= 6;
    /** Unknown Token type. */
    public static final int UNKNOWN	= 7;

    /** The type of this Token. */
    protected int type;
    /** The (possibly empty) string value of this Token. */
    protected String value;

    
    /** Creates a new Token with the given type and value.
	@param type The type of the Token.
	@param value The value of the Token.  May be null or "". */
    public Token(int type, String value) {
	this.type = type;
	this.value = value;
    }

    /**
     * Get the type of the Token.
     * @return The type of the Token.
     */
    public int getType() {
	return type;
    }
    
    /**
     * Get the value of the Token..
     * @return The token value; may be null or "".
     */
    public String getValue() {
	return this.value;
    }

    /**
     * Constructs a string representation of this Token.
     * @return A string representation of the Token.
     */
    public String toString() {
	switch (type) {
	case IDENTIFIER:
	    return "IDENTIFIER[" + value + "]";
	case STRING:
	    return "STRING[" + value + "]";
	case LEFT_PAREN:
	    return "LEFT_PAREN";
	case RIGHT_PAREN:
	    return "RIGHT_PAREN";
	case COMMA:
	    return "COMMA";
	case SEMICOLON:
	    return "SEMICOLON";
	case ASSIGN:
	    return "ASSIGN";
	case UNKNOWN:
	    return "UNKNOWN";
	default:
	    return "ILLEGAL[" + type + ", " + value + "]";
	}
    }

}


