Class Scanner

java.lang.Object
  extended byScanner

public class Scanner
extends java.lang.Object

Scan an input stream looking for tokens defined for a simple language.


Constructor Summary
Scanner(CompilerIO io, SymbolTable reserved)
          Construct a new Scanner object.
 
Method Summary
 Token nextToken()
          Starting with the current character, identify the next Token and return the appropriate Token object to the caller.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Scanner

public Scanner(CompilerIO io,
               SymbolTable reserved)
Construct a new Scanner object. The keywords symbol table is initialized here.

Parameters:
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

nextToken

public Token nextToken()
Starting with the current character, identify the next Token and return the appropriate Token object to the caller. This method calls the private helper methods getCurrentCharacter and acceptCurrentCharacter repeatedly to inspect and advance past characters until it decides that it has found something worthy of being reported as a Token.

Returns:
the appropriate Token object