simple.lexer
Class Lexer

java.lang.Object
  extended by simple.lexer.Lexer

public class Lexer
extends java.lang.Object

This class defines a lexer object that will do a lexical analysis on a stream of characters, and generates Tokens following the rule:

Character Token
( Token.Type.LPAREN
) Token.Type.RPAREN
[+-] Token.Type.TERMOP
[*/] Token.Type.FACTOP
[0-9] Token.Type.NUMBER
<EOF> Token.Type.EOF

Author:
Santoso Wijaya
See Also:
Token, Token.Type

Constructor Summary
Lexer(java.lang.String src)
          Creates a lexer object, passing a source string.
 
Method Summary
 Token getNextToken()
           
 boolean hasMoreTokens()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Lexer

public Lexer(java.lang.String src)
      throws ParseException
Creates a lexer object, passing a source string.

Parameters:
src - the source string
Throws:
ParseException - if unrecognized character is found
Method Detail

hasMoreTokens

public boolean hasMoreTokens()
Returns:
true if there is more token(s) to be returned

getNextToken

public Token getNextToken()
Returns:
null if there is no more token.