/* Tokenizer interface. See implementation for details */ public interface Tokenizer { /** * This is the integer token. An integer is * defined as a sequence of digits starting * with either a dash or a digit and containing * only digits after the first digit */ int INTEGER = -1; /** * This is the float token. A float is defined * as a sequence of digits starting with either a * dash, a period, or a digit and containing only * digits and one period after the first digit. */ int FLOAT = -2; /** * Ths is the word token. A word is defined a letter * followed by a sequence of alphanumeric characters * or underscores (_) without any whitespace. It may * also include a color (:), but this is the termination * of the word. Also, a word is anything between two * quotation signs. Valid escapes (\n, \r. \\, \". etc...) * should also be evaluated in this case. * Finally, if a string such as 2.0.0 is detected, * this should also be considered a word. */ int WORD = -3; /** * This is the operator token. The operator token is defined * as any non alphanumeric character and should be represented * by the java type char */ int OPERATOR = -4; /** * This is the end-of-file token. Such a token represents that * end of the stream has been reached and there exist no more * tokens. */ int EOF = -5; /** * Returns the type of the next token */ int peekAtKind() throws TokenizerException; /** * Returns the next token (unless its not an integer) * @throws TokenizerException if the next token is not an integer */ int getInt() throws TokenizerException; /** * Returns the next token (unless its not a float) * @throws TokenizerException if the next token is not a float */ float getFloat() throws TokenizerException; /** * Returns the next token (unless its not a word) * @throws TokenizerException if the next token is not a word */ String getWord() throws TokenizerException; /** * Returns the next token (unless its not an operator) * @throws TokenizerException if the next token is not an operator */ char getOp() throws TokenizerException; /** * Matches the next character if its a character or throws TokenizerException * @param c the character to match * @throws TokenizerException if the next token is not c */ void match(char c) throws TokenizerException; /** * Matches the next character if its a word or throws TokenizerException * @param s the word to match * @throws TokenizerException if the next token is not s */ void match(String s) throws TokenizerException; /** * Checks if the next token is a character/operator and is c * @param c the value to check against * @return true if the next token is c, false otherwise */ boolean check(char c); /** * Checks if the next token is the word s * @param s the value to check against * @return true if the next token is s, false otherwise */ boolean check(String s); /** * Pushes the latest token requested back. Check individual * implementations as to the effectiveness of this */ void pushBack(); /** * Returns the line number */ int lineNo(); /** * Closes the tokenizer * @throws TokenizerException if there is an I/O Error */ void close() throws TokenizerException; }