// Token.java /** * The Token class is the superclass of tokens generated by the parser. * Tokens are consumed by implementations of the TextMeter interface. * * @author Fredrik Kilander for ID1006 */ public class Token { /** * Holds the characters in this token. */ protected StringBuffer sb; /** * Creates a new token, initialized to the empty string. */ public Token () { sb = new StringBuffer (); } /** * Creates a new token, initialized to the first character given. * * @param c The first character in the new token. */ public Token (char c) { sb = new StringBuffer (); add (c); } /** * Appends a character to the token.j * * @param c The character to append to the token. */ public void add (char c) { sb.append (c); } /** * Returns the string in the token. */ public String toString () { return sb.toString (); } } // class Token