trassare.com

com.trassare.calculator.engine
Class ExpressionScanner

java.lang.Object
  extended by com.trassare.calculator.engine.ExpressionScanner

public class ExpressionScanner
extends Object

A scanner class used for arithmetic expressions.
CS 152, Fall, 2005
Programming Assignment #1

Version:
10 September 2006
Author:
Kenneth Louden, Samuel T Trassare

Nested Class Summary
static class ExpressionScanner.ScanException
          An exception to indicate an IO error in the scanner.
Useful to avoid the checked exception IOException.
CS 152, Fall, 2005
Programming Assignment #1
 
Constructor Summary
ExpressionScanner(PushbackReader stream)
          Constructs an ExpressionScanner object and reads a line of input.
 
Method Summary
 Token getToken()
          Recognize and return the next token in the input, be it an operator, variable, or number.
 void resetScanner(PushbackReader stream)
          Supply the calculator with a new input stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExpressionScanner

public ExpressionScanner(PushbackReader stream)
Constructs an ExpressionScanner object and reads a line of input.

Parameters:
stream - the stream from which to read the input
Method Detail

getToken

public final Token getToken()
Recognize and return the next token in the input, be it an operator, variable, or number.

Returns:
the next token in the input

resetScanner

public final void resetScanner(PushbackReader stream)
Supply the calculator with a new input stream. This function is necessary if input is delivered via a StringReader wrapped in the PushbackReader. Unfortunately StringReaders don't have a "rewind" capability so instead, supply a new input.

Parameters:
stream - the stream from which to read the input

trassare.com