|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object marf.nlp.Parsing.GenericLexicalAnalyzer marf.nlp.Parsing.GrammarCompiler.GrammarAnalyzer
public class GrammarAnalyzer
GrammarAnalyzer class encapsulates functionality required for lexical analysis of a the grammar definition file.
$Id: GrammarAnalyzer.java,v 1.24 2008/01/03 03:21:57 mokhov Exp $
Field Summary | |
---|---|
static java.lang.String |
DEFAULT_ERROR_LOG_FILE
Default filename to log lexical errors. |
static java.lang.String |
DEFAULT_GRAMMAR_FILE
Default filename for a grammar file. |
static java.lang.String |
DEFAULT_SCAN_LOG_FILE
Default filename to log scan output. |
protected GrammarTokenType |
oTokenType
Grammar token type. |
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 | |
---|---|
GrammarAnalyzer()
Constructs a grammar analyzer with the default filename. |
|
GrammarAnalyzer(java.lang.String pstrGrammarFileName)
Constructs a grammar analyzer with the specified grammar filename. |
|
GrammarAnalyzer(SymbolTable poSymTab)
Constructs a grammar analyzer using a predefined symbol table. |
Method Summary | |
---|---|
protected void |
addToTokenList()
Adds the current token to the token list if it is not null and not of backtrack, EOF, or error type. |
protected void |
createEOFToken()
Creates an EOF token as the current token. |
protected void |
createNextToken()
Creates next grammar token from the stream of characters. |
protected void |
createOrdinaryToken()
Creates an ordinary keyword, punctuation, operator, bracket, or lexical error tokens. |
protected void |
createWordToken()
Creates a general word token for keywords, errors, semantic tokens, etc. |
java.util.Vector |
getLexicalGrammarErrors()
Allows querying for the collection of lexical errors. |
static java.lang.String |
getMARFSourceCodeRevision()
Retrieves class' revision. |
Token |
getNextToken()
Returns next grammar token. |
boolean |
init()
Customizes this analyzer for grammar files after calling parent's init() . |
boolean |
serialize(int piOperation)
Load/Save the contents of lists such as Token list and Error list. |
Methods inherited from class marf.nlp.Parsing.GenericLexicalAnalyzer |
---|
createToken, getErrorLogFilename, getErrorsPresent, getLexicalErrors, 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 |
---|
public static final java.lang.String DEFAULT_GRAMMAR_FILE
public static final java.lang.String DEFAULT_ERROR_LOG_FILE
public static final java.lang.String DEFAULT_SCAN_LOG_FILE
protected GrammarTokenType oTokenType
Constructor Detail |
---|
public GrammarAnalyzer()
DEFAULT_GRAMMAR_FILE
public GrammarAnalyzer(java.lang.String pstrGrammarFileName)
pstrGrammarFileName
- the filename of the grammar file to read frompublic GrammarAnalyzer(SymbolTable poSymTab)
poSymTab
- the symbol table referenceDEFAULT_GRAMMAR_FILE
Method Detail |
---|
public boolean init()
init()
. Allows C++, C, and script (#)
style comments; case-sensitive; ignores EOL; and treats
some punctuation a special. Sets default lex out filenames
for standard and error lexical output.
init
in class GenericLexicalAnalyzer
true
of initialization is successfulGenericLexicalAnalyzer.init()
public boolean serialize(int piOperation)
serialize
in class GenericLexicalAnalyzer
piOperation
- 0 means load, 1 means save
true
if the serialization was successfulGenericLexicalAnalyzer.serialize(int)
protected void createEOFToken()
protected void createWordToken() throws NotImplementedException
NotImplementedException
- for dictionary wordsprotected void createOrdinaryToken()
protected void createNextToken() throws LexicalError
LexicalError
- if invalid characters encountered or there
was an I/O problempublic Token getNextToken() throws LexicalError
getNextToken
in class GenericLexicalAnalyzer
LexicalError
- in case of invalid character stream (alphabet) entries foundGenericLexicalAnalyzer.getNextToken()
protected void addToTokenList()
TokenType.BACKTRACK
,
TokenType.EOF
,
TokenType.ERROR
public java.util.Vector getLexicalGrammarErrors()
public static java.lang.String getMARFSourceCodeRevision()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |