marf.nlp.Parsing
Class LexicalAnalyzer

java.lang.Object
  extended by marf.nlp.Parsing.GenericLexicalAnalyzer
      extended by marf.nlp.Parsing.LexicalAnalyzer

public class LexicalAnalyzer
extends GenericLexicalAnalyzer

LexicalAnalyzer class encapsulates the functionality required for lexical analysis of a MARF source program.

$Id: LexicalAnalyzer.java,v 1.21 2008/01/03 03:21:57 mokhov Exp $

Since:
0.3.0.2
Version:
$Revision: 1.21 $
Author:
Serguei Mokhov

Field Summary
protected  boolean bNumberMode
          This flag is used for backtracking when recognizing numbers.
protected  boolean bOperatorMode
          This flag is used for backtracking when recognizing 'ambiguous' operators such as '<>' and '<' and friends.
protected static int NA
          Just a constant used to return an error code "Not Applicable" when no error code applicable in a given situation.
 
Fields inherited from class marf.nlp.Parsing.GenericLexicalAnalyzer
bErrorsPresent, DEFAULT_ERROR_FILE, DEFAULT_OUTPUT_FILE, oFileReader, oLexicalErrors, oStreamTokenizer, oSymTab, oToken, oTokenList, strErrorLogFilename, strOutputFilename, strSourceFilename
 
Constructor Summary
LexicalAnalyzer(SymbolTable poSymTab)
          Constructor with the symbol table as a reference.
 
Method Summary
 java.util.Vector getLexicalErrors()
          Returns the list of lexical errors.
static java.lang.String getMARFSourceCodeRevision()
          Retrieves class' revision.
 Token getNextToken()
          Core method of the MARF LexicalAnalyzer.
 boolean init()
          Initialization routine.
 boolean serialize(int piOperation)
          Load/Save the textual contents of such as Token list and Error list.
protected  int validNum(java.lang.String pstrNum)
          Validates that an incoming string is a valid number or not.
 
Methods inherited from class marf.nlp.Parsing.GenericLexicalAnalyzer
createToken, getErrorLogFilename, getErrorsPresent, getOutputFilename, getSourceFilename, getSymTab, getTokenList, scan, setErrorLogFilename, setOutputFilename, setSourceFilename
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NA

protected static final int NA
Just a constant used to return an error code "Not Applicable" when no error code applicable in a given situation.

See Also:
Constant Field Values

bNumberMode

protected boolean bNumberMode
This flag is used for backtracking when recognizing numbers.


bOperatorMode

protected boolean bOperatorMode
This flag is used for backtracking when recognizing 'ambiguous' operators such as '<>' and '<' and friends.

Constructor Detail

LexicalAnalyzer

public LexicalAnalyzer(SymbolTable poSymTab)
Constructor with the symbol table as a reference.

Parameters:
poSymTab - the symbol table to construct this lexical analyzer
Method Detail

init

public boolean init()
Initialization routine.

Overrides:
init in class GenericLexicalAnalyzer
Returns:
true of initialization is successful
See Also:
GenericLexicalAnalyzer.init()

serialize

public boolean serialize(int piOperation)
Load/Save the textual contents of such as Token list and Error list. 0 means load, 1 means save. Load currently is not implemented. TODO: migrate to MARF's dump/restore machinery.

Specified by:
serialize in class GenericLexicalAnalyzer
Parameters:
piOperation - 0 means load, 1 means save
Returns:
true if the serialization was successful
See Also:
GenericLexicalAnalyzer.serialize(int)

getNextToken

public Token getNextToken()
                   throws LexicalError
Core method of the MARF LexicalAnalyzer.

Specified by:
getNextToken in class GenericLexicalAnalyzer
Returns:
newly recognized lexical token
Throws:
LexicalError - in case of invalid character stream (alphabet) entries found
See Also:
GenericLexicalAnalyzer.getNextToken()

validNum

protected int validNum(java.lang.String pstrNum)
Validates that an incoming string is a valid number or not.

Parameters:
pstrNum - a string containing valid numerical chars
Returns:
int, LexicalError Error code

getLexicalErrors

public java.util.Vector getLexicalErrors()
Returns the list of lexical errors.

Overrides:
getLexicalErrors in class GenericLexicalAnalyzer
Returns:
Vector LexicalErrors

getMARFSourceCodeRevision

public static java.lang.String getMARFSourceCodeRevision()
Retrieves class' revision.

Returns:
revision string


SourceForge Logo