org.ourgrid.common.spec.lexical
Class CommonLexicalAnalyzer

java.lang.Object
  extended by org.ourgrid.common.spec.lexical.CommonLexicalAnalyzer
All Implemented Interfaces:
LexicalAnalyzer

public class CommonLexicalAnalyzer
extends java.lang.Object
implements LexicalAnalyzer

This is a Common Lexical Analyzer. It means that it implements the LexicalAnalyzer interface in a simple way.


Constructor Summary
CommonLexicalAnalyzer(java.lang.String sourceFile)
          The CommonLexicalAnalyzer constructor.
 
Method Summary
 Token getToken()
          This is the main function of the lexical analyzer.
 Token getToken(TokenDelimiter delimiters)
          It will read the next string from source and return the token it represents.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CommonLexicalAnalyzer

public CommonLexicalAnalyzer(java.lang.String sourceFile)
                      throws LexicalException
The CommonLexicalAnalyzer constructor.

Parameters:
sourceFile - - is the String that defines where is the file with the source to be analyzed.
Throws:
LexicalException
Method Detail

getToken

public Token getToken()
               throws LexicalException
Description copied from interface: LexicalAnalyzer
This is the main function of the lexical analyzer. It will read the next string from source and return the token it represents ( the string, the code it has and the line it was found ).

Specified by:
getToken in interface LexicalAnalyzer
Returns:
The next valid token object and null if the source finished
Throws:
LexicalException
See Also:
LexicalAnalyzer.getToken()

getToken

public Token getToken(TokenDelimiter delimiters)
               throws LexicalException
Description copied from interface: LexicalAnalyzer
It will read the next string from source and return the token it represents. This method uses the given set of delimiters to know where the token stops.

Specified by:
getToken in interface LexicalAnalyzer
Parameters:
delimiters - the set of delimiters that determines the end of token.
Returns:
A token where the token's symbol is the string read.
Throws:
LexicalException - if a I/O problem ocurres at the reader
See Also:
LexicalAnalyzer.getToken(TokenDelimiter)