marf.nlp.Parsing.GrammarCompiler
Class GrammarCompiler

java.lang.Object
  extended by marf.Storage.StorageManager
      extended by marf.nlp.Parsing.GrammarCompiler.GrammarCompiler
All Implemented Interfaces:
java.io.Serializable, IStorageManager
Direct Known Subclasses:
ProbabilisticGrammarCompiler

public class GrammarCompiler
extends StorageManager

GrammarCompiler. Compiles source grammar file and produces TT. $Id: GrammarCompiler.java,v 1.18 2005/06/16 19:58:57 mokhov Exp $

Since:
0.3.0
Version:
$Revision: 1.18 $
Author:
Serguei Mokhov
See Also:
Serialized Form

Field Summary
protected  java.lang.String GrammarFileName
          Source grammar filename.
protected  Grammar oGrammar
          Instance of the grammar as a set of production Rules, First and Follow sets.
protected  GrammarAnalyzer oGrammarAnalyzer
          Lexical Analyzer for the grammar.
protected  GrammarElement oGrammarElement
           
protected  Rule oRule
           
protected  Token oToken
           
protected static TransitionTable oTransitionTable
          Instance of the TransitionTable, generated upon the need from the source grammar file.
 
Fields inherited from class marf.Storage.StorageManager
bDumpOnNotFound, iCurrentDumpMode, oObjectToSerialize, strFilename
 
Fields inherited from interface marf.Storage.IStorageManager
DUMP_BINARY, DUMP_CSV_TEXT, DUMP_GZIP_BINARY, DUMP_HTML, DUMP_SQL, DUMP_XML, MARF_INTERFACE_CODE_REVISION, STORAGE_FILE_EXTENSIONS
 
Constructor Summary
GrammarCompiler()
          Default Constructor.
GrammarCompiler(java.lang.String pGrammarFileName)
          Constructor.
 
Method Summary
protected  boolean addIDToken()
           
protected  void addNextRHS()
           
protected  void addTerminalToken()
           
protected  void checkUndefinedNonTerminals()
           
 void compileGrammar()
          Compiles grammar.
protected  void createEOFTerminal()
           
protected  void createEpsilonToken()
           
protected  void createGrammarAnalyzer()
           
protected  boolean createNextNonTerminal()
           
protected  void createRule()
           
protected  void getBusted()
           
 Grammar getGrammar()
           
protected  GrammarElement getGrammarElement(java.lang.String pstrName)
          Returns a grammar element object by it's name (lexeme) if it exists; null otherwise.
 java.lang.String getGrammarFileName()
           
static java.lang.String getMARFSourceCodeRevision()
          Retrieves class' revision.
protected  java.lang.String getNextRHSToken()
           
 TransitionTable getTransitionTable()
           
static TransitionTable loadTT(java.lang.String pstrTTFileName)
          Loads (previously deserialized) state of the TT.
protected  void outputStats()
           
protected  void parseGrammar()
          Parsing grammar.
 boolean serialize(int piOperation)
          Text serialization routine for grammar compilation.
 
Methods inherited from class marf.Storage.StorageManager
backSynchronizeObject, dump, dumpBinary, dumpCSV, dumpGzipBinary, dumpHTML, dumpSQL, dumpXML, enableDumpOnNotFound, getDefaultExtension, getDefaultExtension, getDumpMode, getFilename, restore, restoreBinary, restoreCSV, restoreGzipBinary, restoreHTML, restoreSQL, restoreXML, setDumpMode, setFilename
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

oGrammar

protected Grammar oGrammar
Instance of the grammar as a set of production Rules, First and Follow sets.


GrammarFileName

protected java.lang.String GrammarFileName
Source grammar filename.


oGrammarAnalyzer

protected GrammarAnalyzer oGrammarAnalyzer
Lexical Analyzer for the grammar.


oTransitionTable

protected static TransitionTable oTransitionTable
Instance of the TransitionTable, generated upon the need from the source grammar file.


oGrammarElement

protected GrammarElement oGrammarElement

oToken

protected Token oToken

oRule

protected Rule oRule
Constructor Detail

GrammarCompiler

public GrammarCompiler()
Default Constructor.


GrammarCompiler

public GrammarCompiler(java.lang.String pGrammarFileName)
Constructor.

Parameters:
pGrammarFileName -
Method Detail

createGrammarAnalyzer

protected void createGrammarAnalyzer()

compileGrammar

public void compileGrammar()
Compiles grammar. Compilation consitis of parsing source grammar file, creating rules, Terminals, Non-Terminals; then computes first and follow sets, and fills in a TransitionTable data structure.


createEpsilonToken

protected void createEpsilonToken()

createNextNonTerminal

protected boolean createNextNonTerminal()

createRule

protected void createRule()

outputStats

protected void outputStats()

getNextRHSToken

protected java.lang.String getNextRHSToken()

addNextRHS

protected void addNextRHS()

addIDToken

protected boolean addIDToken()

addTerminalToken

protected void addTerminalToken()

getBusted

protected void getBusted()

createEOFTerminal

protected void createEOFTerminal()

checkUndefinedNonTerminals

protected void checkUndefinedNonTerminals()

parseGrammar

protected void parseGrammar()
Parsing grammar.


getGrammarElement

protected GrammarElement getGrammarElement(java.lang.String pstrName)
Returns a grammar element object by it's name (lexeme) if it exists; null otherwise.

Returns:
GrammarElement

loadTT

public static TransitionTable loadTT(java.lang.String pstrTTFileName)
Loads (previously deserialized) state of the TT. Method declared as static and can be called without an instance of the GrammarCompiler.


serialize

public boolean serialize(int piOperation)
Text serialization routine for grammar compilation.


getGrammar

public final Grammar getGrammar()
Returns:
Grammar object

getGrammarFileName

public final java.lang.String getGrammarFileName()
Returns:
GrammarFileName

getTransitionTable

public final TransitionTable getTransitionTable()
Returns:
oTransitionTable

getMARFSourceCodeRevision

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

Returns:
revision string