cgp.translators
Class CGIFParser

java.lang.Object
  |
  +--cgp.translators.CGIFParser

public class CGIFParser
extends java.lang.Object
implements Parser


Field Summary
private  AntlrCGIFLexer lexer
           
private  AntlrCGIFParser parser
           
private  java.lang.String path
           
private  java.io.DataInputStream stream
           
private static boolean treeOn
           
 
Constructor Summary
CGIFParser()
           
 
Method Summary
private  java.lang.String createExMsg(java.lang.String prefix, java.lang.Exception e)
          Creates a message for a parser exception given another exception.
 AntlrCGIFParser getParser()
          Return the parser object.
 java.lang.String getParseTree()
          Returns a parse tree, if available, as a string.
 java.lang.Class getUnitClass()
          Returns a Class object that indicates what class the parseUnit() method will return.
 void initializeParser(java.io.File f, notio.KnowledgeBase kBase, notio.TranslationContext tContext)
          Initializes the parser to parse the specified character reader.
 void initializeParser(java.io.Reader reader, notio.KnowledgeBase kBase, notio.TranslationContext tContext)
          Initializes the parser to parse the specified character reader.
 void initializeParser(java.lang.String s, notio.KnowledgeBase kBase, notio.TranslationContext tContext)
          Initializes the parser to parse the specified character reader.
 notio.Actor parseActor()
          Attempts to parse an actor from the input stream.
 notio.Concept parseConcept()
          Attempts to parse a concept from the input stream.
 notio.Graph parseGraph()
          Attempts to parse a graph from the input stream.
 notio.Graph[] parseGraphStream()
          Attempts to parse a graph stream from the input.
 notio.Graph parseOutermostContext()
          Attempts to parse a graph which is treated as the outermost context for purposes for scoping.
 notio.Relation parseRelation()
          Attempts to parse a relation from the input stream.
 java.lang.Object parseUnit()
          Attempts to parse the default unit from the input stream.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

treeOn

private static boolean treeOn

path

private java.lang.String path

stream

private java.io.DataInputStream stream

lexer

private AntlrCGIFLexer lexer

parser

private AntlrCGIFParser parser
Constructor Detail

CGIFParser

public CGIFParser()
Method Detail

initializeParser

public void initializeParser(java.io.File f,
                             notio.KnowledgeBase kBase,
                             notio.TranslationContext tContext)
                      throws notio.ParserException
Initializes the parser to parse the specified character reader. Precondition: File represents a readable CGIF file.
Specified by:
initializeParser in interface Parser
Parameters:
f - the file whose contents are to be parsed.
kBase - the knowledge base to be used while parsing.
tContext - the translation context to be used while parsing.
Throws:
notio.ParserException - if an error occurs while initializing the parser.

initializeParser

public void initializeParser(java.lang.String s,
                             notio.KnowledgeBase kBase,
                             notio.TranslationContext tContext)
                      throws notio.ParserException
Initializes the parser to parse the specified character reader. Precondition: The string represents a readable CGIF file.
Specified by:
initializeParser in interface Parser
Parameters:
s - the string whose contents are to be parsed.
kBase - the knowledge base to be used while parsing.
tContext - the translation context to be used while parsing.
Throws:
notio.ParserException - if an error occurs while initializing the parser.

initializeParser

public void initializeParser(java.io.Reader reader,
                             notio.KnowledgeBase kBase,
                             notio.TranslationContext tContext)
                      throws notio.ParserException
Initializes the parser to parse the specified character reader.
Parameters:
reader - the reader whose contents are to be parsed.
kBase - the knowledge base to be used while parsing.
tContext - the translation context to be used while parsing.
Throws:
notio.ParserException - if an error occurs while initializing the parser.
notio.UnimplementedFeatureException - if this parser does support a java.io.Reader

getUnitClass

public java.lang.Class getUnitClass()
Returns a Class object that indicates what class the parseUnit() method will return.
Returns:
a Class object that indicates what class the parseUnit() method will return.
See Also:
Parser.parseUnit()

parseUnit

public java.lang.Object parseUnit()
                           throws notio.ParserException
Attempts to parse the default unit from the input stream. The default unit is whatever a particular parser is usually intended to parse.
Returns:
the unit object parsed from the input stream.
Throws:
notio.ParserException - if an error occurs while parsing.

parseOutermostContext

public notio.Graph parseOutermostContext()
                                  throws notio.ParserException
Attempts to parse a graph which is treated as the outermost context for purposes for scoping. This method should be used instead of parseGraph() when no translation information is to be used from previous translation sessions and when the parser can safely assume that the graph is "self-contained".
Returns:
the graph parsed from the input stream.
Throws:
notio.ParserException - if an error occurs while parsing.
notio.UnimplementedFeatureException - if this parser does not support this parsing method.

parseGraphStream

public notio.Graph[] parseGraphStream()
                               throws notio.ParserException
Attempts to parse a graph stream from the input.
Specified by:
parseGraphStream in interface Parser
Throws:
notio.ParserException - if an error occurs while parsing.
notio.UnimplementedFeatureException - if this parser does not support this parsing method.

parseGraph

public notio.Graph parseGraph()
                       throws notio.ParserException
Attempts to parse a graph from the input stream.
Returns:
the graph parsed from the input stream.
Throws:
notio.ParserException - if an error occurs while parsing.
notio.UnimplementedFeatureException - if this parser does not support this parsing method.

parseConcept

public notio.Concept parseConcept()
                           throws notio.ParserException
Attempts to parse a concept from the input stream.
Returns:
the concept parsed from the input stream.
Throws:
notio.ParserException - if an error occurs while parsing.
notio.UnimplementedFeatureException - if this parser does not support this parsing method.

parseRelation

public notio.Relation parseRelation()
                             throws notio.ParserException
Attempts to parse a relation from the input stream.
Returns:
the relation parsed from the input stream.
Throws:
notio.ParserException - if an error occurs while parsing.
notio.UnimplementedFeatureException - if this parser does not support this parsing method.

parseActor

public notio.Actor parseActor()
                       throws notio.ParserException
Attempts to parse an actor from the input stream.
Returns:
the actor parsed from the input stream.
Throws:
notio.ParserException - if an error occurs while parsing.
notio.UnimplementedFeatureException - if this parser does not support this parsing method.

getParseTree

public java.lang.String getParseTree()
Returns a parse tree, if available, as a string. This may be empty. This can be useful for diagnostic purposes. Pre-condition: a parser exists and a parsing method has been invoked.
Specified by:
getParseTree in interface Parser
Throws:
notio.UnimplementedFeatureException - if this parser does not support the returning of a parse tree.

createExMsg

private java.lang.String createExMsg(java.lang.String prefix,
                                     java.lang.Exception e)
Creates a message for a parser exception given another exception. The parse tree is also optionally included.
Parameters:
prefix - some preamble text.
e - the exception
Returns:
the message string

getParser

public AntlrCGIFParser getParser()
Return the parser object.
Returns:
the parser object