Class TokenScanner

java.lang.Object
  extended by TokenScanner

public class TokenScanner
extends java.lang.Object

A "scanner" for Tokens that doesn't need to have whitespace separated Tokens. There are no delimiters. Recognizes the operators from Token.OperatorList. These are all operators from Token including parentheses. Recognizes simple non-negative real numbers with or without a decimal point. Must have digits on both sides of the decimal point if there is one. Does not recognize negative numbers. Will tokenize them as minus and a number. Throws NoSuchElementException if Token is requested but doesn't exist at current location in source. There is no error recovery or peek.

Author:
Beth Katz

Constructor Summary
TokenScanner(java.lang.String s)
          Constructs a TokenScanner from a non-empty String
 
Method Summary
 boolean hasNextToken()
          Whether or not there is a Token available.
 Token nextToken()
          Provides the next Token from source.
 boolean reachedEnd()
          Returns whether or not entire source was tokenized.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TokenScanner

public TokenScanner(java.lang.String s)
Constructs a TokenScanner from a non-empty String

Method Detail

hasNextToken

public boolean hasNextToken()
Whether or not there is a Token available.

Returns:
true if there is a Token available, false if not

nextToken

public Token nextToken()
Provides the next Token from source. Throws NoSuchElementException if there is no Token.

Returns:
next Token

reachedEnd

public boolean reachedEnd()
Returns whether or not entire source was tokenized.

Returns:
true if all of source has been tokenized and there is no more data, false if not