public class TokenDispenser
extends java.io.StreamTokenizer
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
EOF |
Constructor and Description |
---|
TokenDispenser(java.lang.String input)
Creates a token dispenser for a given string input.
|
Modifier and Type | Method and Description |
---|---|
void |
advance()
Parses the next token in the input.
|
char |
getChar()
Returns the most recently parsed token as a single character.
|
double |
getNumber()
Returns the most recently parsed token as a number.
|
java.lang.Object |
getToken()
Returns the most recently parsed token in the input.
|
java.lang.String |
getWord()
Returns the most recently parsed token as a word.
|
boolean |
tokenIsEOF()
Tests for whether the most recently parsed token is EOF
(end of file).
|
boolean |
tokenIsLeftParen()
Tests for whether the most recently parsed token is a
left parenthesis.
|
boolean |
tokenIsNumber()
Tests for whether the most recently parsed token is a number.
|
boolean |
tokenIsOperator()
Tests for whether the most recently parsed token is a
binary operator (+, -, *, /).
|
boolean |
tokenIsRightParen()
Tests for whether the most recently parsed token is a
right parenthesis.
|
boolean |
tokenIsWord()
Tests for whether the most recently parsed token is a word
(string of alphabetic characters).
|
public static final java.lang.String EOF
public TokenDispenser(java.lang.String input)
input
- the string inputpublic void advance()
public java.lang.Object getToken()
public boolean tokenIsNumber()
public double getNumber()
public boolean tokenIsWord()
public java.lang.String getWord()
public boolean tokenIsEOF()
public boolean tokenIsOperator()
public boolean tokenIsLeftParen()
public boolean tokenIsRightParen()
public char getChar()