|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectScanner
public class 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 SymbolTable |
keywords
Symbol table 0 stores the identifiers that are to be recognized as keywords, along with their specific Token.xyz values. |
private java.lang.String |
srcLine
the current line of the source file, null if we have read to end of file. |
Constructor Summary | |
---|---|
Scanner(CompilerIO io,
SymbolTable reserved)
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 SymbolTable keywords
private CompilerIO io
private java.lang.String srcLine
private int idx
Constructor Detail |
---|
public Scanner(CompilerIO io, SymbolTable reserved)
io
- the CompilerIO object to use in reading and writing files.reserved
- the SymbolTable manager. Table 0 is assumed to be
the reserved word table and is initialized in this constructor.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 |