Class Scanner

java.lang.Object
  |
  +--Scanner

public class Scanner
extends Object

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


Constructor Summary
Scanner(CompilerIO io)
          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)
Construct a new Scanner object. The first line of the source file is read in here but no processing is actually done until the first call to nextToken. The keywords HashMap is initialized here.

Parameters:
io - the CompilerIO object to use in reading and writing files.
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