Read an expression (e.g., 3 + 4 * x) and return a set of tokens that represent the components of the expression.
Public Member Functions | |
Scanner (String exp) | |
Token | getToken () |
Return the next expression token. | |
void | pushToken (Token t) |
"Push" a token back into the token stream. | |
boolean | isEOL () |
Private Member Functions | |
void | putChar (char ch) |
Add a character to the array that contains the token string. | |
void | getIdent (char ch) |
Copy a string of identifier characters into the token character array. | |
void | getInt (char ch) |
Copy a string of numbers into the token character array. | |
void | skipSpaces () |
Skip white space characters. | |
TokenType | lexer () |
The lexer method does simple "lexical analysis", which divides the character stream into a set of tokens. | |
Private Attributes | |
String | mExp = null |
int | mExpLen = 0 |
boolean | mEOL = false |
int | mCursor = 0 |
char[] | mCharBuf = new char[ 80 ] |
int | mBufIx = 0 |
LinkedList | mPushList = new LinkedList() |
A First In, First Out list for tokens which have been "pushed back". |
|
|
|
Copy a string of identifier characters into the token character array.
|
|
Copy a string of numbers into the token character array.
|
|
Return the next expression token.
|
|
|
|
The lexer method does simple "lexical analysis", which divides the character stream into a set of tokens.
|
|
"Push" a token back into the token stream. If a token is pushed back and then getToken() is called, the pushed token will the the token returned by getToken().
|
|
Add a character to the array that contains the token string.
|
|
Skip white space characters.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
A First In, First Out list for tokens which have been "pushed back".
|