jdrew.oo.util
Class POSLParser

java.lang.Object
  extended by jdrew.oo.util.POSLParser

public class POSLParser
extends java.lang.Object

Title: OO jDREW

This class serves as a wrapper for the parser that is generated from the POSLParser-Java.g ANTLR grammar. The classes for the ANTLR generated parser are part of the jdrew.oo.util.parsing package. The methods in this class take the appropriate reader (StringReader, FileReader), then a lexcographical analyzer is created on that reader; once this is done a jdrew.oo.util.parsing.POSLParser object is created on the lexer and the appropriate parsing routine is invoked.

Description: Reasoning Engine for the Semantic Web - Supporting OO RuleML 0.88

Copyright: Copyright (c) 2005

Version:
0.89
Author:
Marcel Ball

Constructor Summary
POSLParser()
           
 
Method Summary
 java.util.Iterator iterator()
          Returns an interator over the clauses that are stored in the parsers internal buffer; the buffer is not automatically cleared after a call to iterator().
 void parseDCFile(java.lang.String filename)
          This method is used to parse a group of clauses stored in a local file.
 DefiniteClause parseDefiniteClause(java.lang.String clause)
          This method is used to parse a single definite clause, stored in a String.
 void parseDefiniteClauses(java.lang.String clauses)
          This method is used to parse a group of clauses, stored in a String.
 void parseInputStream(java.io.InputStream is)
          This method is used to parse a group of clauses read from an InputStream (keyboard, socket, etc.).
 DefiniteClause parseQueryString(java.lang.String query)
          This method is used to parse a query - stored in a String.
 DefiniteClause parseQueryStringT(java.lang.String query)
           
 void reset()
          Clears the parsers internal clause buffer.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

POSLParser

public POSLParser()
Method Detail

iterator

public java.util.Iterator iterator()
Returns an interator over the clauses that are stored in the parsers internal buffer; the buffer is not automatically cleared after a call to iterator(). To clear the buffer a call to reset() must be invoked.

Returns:
Iterator

reset

public void reset()
Clears the parsers internal clause buffer.


parseDefiniteClause

public DefiniteClause parseDefiniteClause(java.lang.String clause)
                                   throws antlr.RecognitionException,
                                          antlr.TokenStreamException
This method is used to parse a single definite clause, stored in a String. The DefiniteClause object that represents the parsed clause is returned directly to the user and not added to the internal clause buffer.

Parameters:
clause - String A string containing the clause to be parsed. If the string contains multiple clauses only the first clause will be parsed.
Returns:
DefiniteClause The DefiniteClause object that represents the parsed clause.
Throws:
antlr.RecognitionException
antlr.TokenStreamException

parseQueryString

public DefiniteClause parseQueryString(java.lang.String query)
                                throws antlr.RecognitionException,
                                       antlr.TokenStreamException
This method is used to parse a query - stored in a String. The DefiniteClause object that represents the parsed query is returned directly to the user and not added to the internal clause buffer.

Parameters:
query - String A string containing the query to be parsed. If the string contains multiple queries only the first query will be parsed.
Returns:
DefiniteClause The DefiniteClause object that represents the parsed query.
Throws:
antlr.RecognitionException
antlr.TokenStreamException

parseQueryStringT

public DefiniteClause parseQueryStringT(java.lang.String query)
                                 throws antlr.RecognitionException,
                                        antlr.TokenStreamException
Throws:
antlr.RecognitionException
antlr.TokenStreamException

parseDefiniteClauses

public void parseDefiniteClauses(java.lang.String clauses)
                          throws antlr.RecognitionException,
                                 antlr.TokenStreamException
This method is used to parse a group of clauses, stored in a String. The parsed clauses (DefiniteClause objects) are added to the internal clause buffer and not returned directly to the caller. The an iterator over the clauses can be retrieved by invoking the iterator() method.

Parameters:
clauses - String A string containing one or more clauses.
Throws:
antlr.RecognitionException
antlr.TokenStreamException

parseDCFile

public void parseDCFile(java.lang.String filename)
                 throws java.io.FileNotFoundException,
                        antlr.RecognitionException,
                        antlr.TokenStreamException
This method is used to parse a group of clauses stored in a local file. The full path to the filename should be used. A FileReader object is created using the filename as the path; then the reader is passed to the parseReader(Reader) method.

Parameters:
filename - String A string containing the complete path to the file.
Throws:
java.io.FileNotFoundException
antlr.RecognitionException
antlr.TokenStreamException

parseInputStream

public void parseInputStream(java.io.InputStream is)
                      throws antlr.RecognitionException,
                             antlr.TokenStreamException
This method is used to parse a group of clauses read from an InputStream (keyboard, socket, etc.). A InputStreamReader is created using the InputStream and passed to the parseReader(Reader) method. Clauses are parsed until a End of File (EOF) character is reached (Typically CTRL-D on Unix-like systems and CTRL-Z on Windows).

Parameters:
is - InputStream The input stream to read clauses from.
Throws:
antlr.RecognitionException
antlr.TokenStreamException