|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object marf.nlp.Parsing.GenericLexicalAnalyzer
public abstract class GenericLexicalAnalyzer
Generic Lexical Analyzer.
(C) 2001 Serguei A. Mokhov
(C) 2002 - 2008 The MARF Research and Development Group
$Id: GenericLexicalAnalyzer.java,v 1.18 2008/01/03 03:21:57 mokhov Exp $
Field Summary | |
---|---|
protected boolean |
bErrorsPresent
An indicator of presence of lexical errors. |
static java.lang.String |
DEFAULT_ERROR_FILE
Default filename for the error log. |
static java.lang.String |
DEFAULT_OUTPUT_FILE
Default filename for the output. |
protected java.io.FileReader |
oFileReader
Internal reference to the file reader of a file to perform lexical analysis of. |
protected java.util.Vector |
oLexicalErrors
A collection of lexical errors (if any). |
protected java.io.StreamTokenizer |
oStreamTokenizer
A tokenizer used to split the stream of characters into a stream of tokens. |
protected SymbolTable |
oSymTab
A reference to local symbol table. |
protected Token |
oToken
Current token being processed. |
protected java.util.Vector |
oTokenList
A list of tokens extracted so far. |
protected java.lang.String |
strErrorLogFilename
File name of a file which serves as an lexical errors log. |
protected java.lang.String |
strOutputFilename
File name of a file which serves as an output of the Lexical Analyzer. |
protected java.lang.String |
strSourceFilename
File name of a file which serves as an input of the Lexical Analyzer. |
Constructor Summary | |
---|---|
GenericLexicalAnalyzer(SymbolTable poSymTab)
Constructor with symbol table. |
Method Summary | |
---|---|
Token |
createToken(java.lang.String pstrLexeme,
TokenSubType poTokenSubType)
Creates an instance of a Token data structure
provided its type and lexeme, and location is calculated
dynamically by the StreamTokenizer . |
java.lang.String |
getErrorLogFilename()
Access method for the ErrorLogFilename property. |
boolean |
getErrorsPresent()
Determines if the ErrorsPresent property is true. |
java.util.Vector |
getLexicalErrors()
Allows querying for actual lexical errors happened during scanning. |
static java.lang.String |
getMARFSourceCodeRevision()
Retrieves class' revision. |
abstract Token |
getNextToken()
Core method of the LexicalAnalyzer. |
java.lang.String |
getOutputFilename()
Access method for the OutputFilename property. |
java.lang.String |
getSourceFilename()
Access method for the SourceFilename property. |
SymbolTable |
getSymTab()
Access method for the SymTab property. |
java.util.Vector |
getTokenList()
Access method for the TonkenList property. |
boolean |
init()
Default initialization routine. |
void |
scan()
Scan for tokens through the input stream. |
abstract boolean |
serialize(int piOperation)
Load/Save the contents of lists such as Token list and Error list. |
void |
setErrorLogFilename(java.lang.String pstrErrorLogFilename)
Sets the value of the ErrorLogFilename property. |
void |
setOutputFilename(java.lang.String pstrOutputFilename)
Sets the value of the OutputFilename property. |
void |
setSourceFilename(java.lang.String pstrSourceFilename)
Sets the value of the SourceFilename property. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String DEFAULT_OUTPUT_FILE
public static final java.lang.String DEFAULT_ERROR_FILE
protected java.io.FileReader oFileReader
protected java.io.StreamTokenizer oStreamTokenizer
protected java.lang.String strSourceFilename
protected java.lang.String strOutputFilename
protected java.lang.String strErrorLogFilename
protected boolean bErrorsPresent
protected java.util.Vector oTokenList
protected SymbolTable oSymTab
protected java.util.Vector oLexicalErrors
protected Token oToken
Constructor Detail |
---|
public GenericLexicalAnalyzer(SymbolTable poSymTab)
poSymTab
- symbol table to use.Method Detail |
---|
public boolean init()
true
of initialization is successfulpublic void scan() throws LexicalError
LexicalError
- as a notification there were one more more lexical errors;
the actual error messages can be queried via getLexicalErrors()
.getLexicalErrors()
public abstract boolean serialize(int piOperation)
piOperation
- 0 means load, 1 means save
true
if the serialization was successfulpublic abstract Token getNextToken() throws LexicalError
LexicalError
- in case of invalid character stream (alphabet) entries foundpublic Token createToken(java.lang.String pstrLexeme, TokenSubType poTokenSubType)
Token
data structure
provided its type and lexeme, and location is calculated
dynamically by the StreamTokenizer
.
TODO: reliably get a character position within a line.
pstrLexeme
- token's spellingpoTokenSubType
- token's data type
public java.lang.String getSourceFilename()
public void setSourceFilename(java.lang.String pstrSourceFilename)
pstrSourceFilename
- the new value of the SourceFilename propertypublic java.lang.String getOutputFilename()
public void setOutputFilename(java.lang.String pstrOutputFilename)
pstrOutputFilename
- the new value of the OutputFilename propertypublic java.lang.String getErrorLogFilename()
public void setErrorLogFilename(java.lang.String pstrErrorLogFilename)
pstrErrorLogFilename
- the new value of the ErrorLogFilename propertypublic boolean getErrorsPresent()
true
if the ErrorsPresent property is truepublic java.util.Vector getTokenList()
public SymbolTable getSymTab()
public java.util.Vector getLexicalErrors()
public static java.lang.String getMARFSourceCodeRevision()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |