|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--Scanner
Scan an input stream looking for tokens defined for a simple language.
Field Summary | |
private int |
idx
Zero-based offset to the next unaccepted character in the srcLine. |
private CompilerIO |
io
The CompilerIO object that is managing all of our IO. |
private HashMap |
keywords
The keywords HashMap stores the identifiers that are to be recognized as keywords, along with their specific Token.xyz values. |
private String |
srcLine
the current line of the source file, null if we have read to end of file. |
Constructor Summary | |
Scanner(CompilerIO io)
Construct a new Scanner object. |
Method Summary | |
private void |
acceptCurrentCharacter()
Accept the previously returned character, and advance the index to the next available character. |
private char |
getCurrentCharacter()
Get the current character from the source file. |
private void |
invalidCharacter(char c)
Report invalid character. |
Token |
nextToken()
Starting with the current character, identify the next Token and return the appropriate Token object to the caller. |
private void |
skipWhitespace()
Skip over whitespace characters. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private HashMap keywords
private CompilerIO io
private String srcLine
private int idx
Constructor Detail |
public Scanner(CompilerIO io)
io
- the CompilerIO object to use in reading and writing files.Method Detail |
public Token nextToken()
private void skipWhitespace()
private void invalidCharacter(char c)
c
- the invalid characterprivate char getCurrentCharacter()
private void acceptCurrentCharacter()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |