ai.krr.propositions
Class IntEncodedClause.CnfIntEncodedClauseListAdaptor

java.lang.Object
  extended by ai.krr.propositions.IntEncodedClause.CnfIntEncodedClauseListAdaptor
All Implemented Interfaces:
inf.compilers.SyntaxAdaptor<IntEncodedClause.IntEncodedClauseList>
Enclosing class:
IntEncodedClause

protected static class IntEncodedClause.CnfIntEncodedClauseListAdaptor
extends java.lang.Object
implements inf.compilers.SyntaxAdaptor<IntEncodedClause.IntEncodedClauseList>


Field Summary
protected static inf.compilers.LexicalAnalyzer.TokenType cnfTT
          the token types used
protected static inf.compilers.LexicalAnalyzer.TokenType ignorableTT
          the token types used
protected static inf.compilers.LexicalAnalyzer.TokenType minusTT
          the token types used
protected static inf.compilers.LexicalAnalyzer.TokenType posintTT
          the token types used
protected  java.util.Properties props
          the properties used for reading and writing
protected static inf.compilers.LexicalAnalyzer.TokenType pTT
          the token types used
protected  inf.compilers.LexicalAnalyzer scanner
          the lexical analyzer used for tokenizing the input
protected static inf.compilers.LexicalAnalyzer.TokenType zeroTT
          the token types used
 
Constructor Summary
IntEncodedClause.CnfIntEncodedClauseListAdaptor()
           This constructor creates a SyntaxAdaptor that can be used to read statements in a (propositional) KIF syntax and create a propositional Sentence for it, or it can be used to write out a propositional Sentence in KIF syntax.
 
Method Summary
protected  java.lang.Object clone()
           
 java.lang.Class<IntEncodedClause.IntEncodedClauseList> getInternalClass()
           This function returns the Class that holds the internal representation this adaptor translates to and from.
 java.lang.String getProperty(java.lang.String key)
           This function gets the property that is associated with the given key.
 java.lang.String getSyntaxName()
           This function returns the name that should identify the syntactical language that this adaptor translates to and from.
static IntEncodedClause.IntEncodedClauseList parseClauseList(java.io.Reader r, java.util.Properties props)
           This function attempts to parse a propositional Sentence in KIF syntax from the underlying LexicalAnalyzer.
 void prettyPrint(int indent, IntEncodedClause.IntEncodedClauseList iecls, java.io.Writer w)
           This function takes an IntEncodedClauseList which is a Java Object in the internal representation, and writes it to the given Writer as a string conforming to the CNF syntax.
 IntEncodedClause.IntEncodedClauseList read(java.io.Reader r)
           This function attempts to parse characters from the given Reader until an IntEncodedClauseList that represents an object in the internal representation has been parsed.
 void setProperty(java.lang.String key, java.lang.String value)
           This function sets the property associated with the given key to the given value.
 void write(IntEncodedClause.IntEncodedClauseList iecls, java.io.Writer w)
           This function takes an IntEncodedClauseList which is a Java Object in the internal representation, and writes it to the given Writer as a string conforming to the CNF syntax.
static void writeClauseList(IntEncodedClause.IntEncodedClauseList iecls, java.io.Writer w, java.util.Properties props)
           This function takes an IntEncodedClauseList which is a Java Object in the internal representation, and writes it to the given Writer as a string conforming to the CNF syntax.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ignorableTT

protected static inf.compilers.LexicalAnalyzer.TokenType ignorableTT
the token types used


pTT

protected static inf.compilers.LexicalAnalyzer.TokenType pTT
the token types used


cnfTT

protected static inf.compilers.LexicalAnalyzer.TokenType cnfTT
the token types used


posintTT

protected static inf.compilers.LexicalAnalyzer.TokenType posintTT
the token types used


minusTT

protected static inf.compilers.LexicalAnalyzer.TokenType minusTT
the token types used


zeroTT

protected static inf.compilers.LexicalAnalyzer.TokenType zeroTT
the token types used


scanner

protected inf.compilers.LexicalAnalyzer scanner
the lexical analyzer used for tokenizing the input


props

protected java.util.Properties props
the properties used for reading and writing

Constructor Detail

IntEncodedClause.CnfIntEncodedClauseListAdaptor

public IntEncodedClause.CnfIntEncodedClauseListAdaptor()

This constructor creates a SyntaxAdaptor that can be used to read statements in a (propositional) KIF syntax and create a propositional Sentence for it, or it can be used to write out a propositional Sentence in KIF syntax.

Method Detail

clone

protected java.lang.Object clone()
                          throws java.lang.CloneNotSupportedException
Overrides:
clone in class java.lang.Object
Throws:
java.lang.CloneNotSupportedException

getInternalClass

public java.lang.Class<IntEncodedClause.IntEncodedClauseList> getInternalClass()

This function returns the Class that holds the internal representation this adaptor translates to and from.

Specified by:
getInternalClass in interface inf.compilers.SyntaxAdaptor<IntEncodedClause.IntEncodedClauseList>
Returns:
the internal representation Class adapted to

getSyntaxName

public java.lang.String getSyntaxName()

This function returns the name that should identify the syntactical language that this adaptor translates to and from.

Specified by:
getSyntaxName in interface inf.compilers.SyntaxAdaptor<IntEncodedClause.IntEncodedClauseList>
Returns:
the name of the language adapted to

write

public void write(IntEncodedClause.IntEncodedClauseList iecls,
                  java.io.Writer w)
           throws inf.compilers.ExpressivenessException,
                  java.io.IOException

This function takes an IntEncodedClauseList which is a Java Object in the internal representation, and writes it to the given Writer as a string conforming to the CNF syntax.

Specified by:
write in interface inf.compilers.SyntaxAdaptor<IntEncodedClause.IntEncodedClauseList>
Parameters:
iecls - a list of clauses in the internal representation
w - the Writer to which the syntactical translation is written
Throws:
inf.compilers.ExpressivenessException - if the syntactical language cannot represent the given clauses
java.io.IOException - if writing to the given Writer fails

prettyPrint

public void prettyPrint(int indent,
                        IntEncodedClause.IntEncodedClauseList iecls,
                        java.io.Writer w)
                 throws inf.compilers.ExpressivenessException,
                        java.io.IOException

This function takes an IntEncodedClauseList which is a Java Object in the internal representation, and writes it to the given Writer as a string conforming to the CNF syntax.

Specified by:
prettyPrint in interface inf.compilers.SyntaxAdaptor<IntEncodedClause.IntEncodedClauseList>
Parameters:
indent - the amount of indentation for the first line
iecls - a list of clauses in the internal representation
w - the Writer to which the syntactical translation is written
Throws:
inf.compilers.ExpressivenessException - if the syntactical language cannot represent the given clauses
java.io.IOException - if writing to the given Writer fails

read

public IntEncodedClause.IntEncodedClauseList read(java.io.Reader r)
                                           throws inf.compilers.ExpressivenessException,
                                                  java.text.ParseException,
                                                  java.io.IOException

This function attempts to parse characters from the given Reader until an IntEncodedClauseList that represents an object in the internal representation has been parsed.

Specified by:
read in interface inf.compilers.SyntaxAdaptor<IntEncodedClause.IntEncodedClauseList>
Parameters:
r - the Reader from which the representation is to be parsed
Returns:
the target internal representation
Throws:
inf.compilers.ExpressivenessException - if the internal representation class is not expressive enough for the given clauses
java.text.ParseException - if there is a syntax error in the given string
java.io.IOException - if reading from the Reader fails

getProperty

public java.lang.String getProperty(java.lang.String key)

This function gets the property that is associated with the given key. Not e that the key should not be null.

Specified by:
getProperty in interface inf.compilers.SyntaxAdaptor<IntEncodedClause.IntEncodedClauseList>
Returns:
the property for the given key (or null if undefined)

setProperty

public void setProperty(java.lang.String key,
                        java.lang.String value)

This function sets the property associated with the given key to the given value. The given key must not be null, but the value may be.

Specified by:
setProperty in interface inf.compilers.SyntaxAdaptor<IntEncodedClause.IntEncodedClauseList>
Parameters:
key - the key with which the value is associated
value - the associated value

writeClauseList

public static void writeClauseList(IntEncodedClause.IntEncodedClauseList iecls,
                                   java.io.Writer w,
                                   java.util.Properties props)
                            throws inf.compilers.ExpressivenessException,
                                   java.io.IOException

This function takes an IntEncodedClauseList which is a Java Object in the internal representation, and writes it to the given Writer as a string conforming to the CNF syntax.

Parameters:
iecls - a list of clauses in the internal representation
w - the Writer to which the syntactical translation is written
props - the Properties used for writing
Throws:
inf.compilers.ExpressivenessException - if the syntactical language cannot represent the given statement
java.io.IOException - if writing to the given Writer fails

parseClauseList

public static IntEncodedClause.IntEncodedClauseList parseClauseList(java.io.Reader r,
                                                                    java.util.Properties props)
                                                             throws inf.compilers.ExpressivenessException,
                                                                    java.text.ParseException,
                                                                    java.io.IOException

This function attempts to parse a propositional Sentence in KIF syntax from the underlying LexicalAnalyzer. Since the target representation is propositional and KIF is a much more expressive syntax, there are many reasons why an ExpressivenessException may be thrown. However, some of these may look like syntax problem to this parser and thus will be thrown as ParseExceptions.

Parameters:
scanner - the LexicalAnalyzer from which character input is read
props - the properties used for reading
Returns:
the Sentence corresponding to the input from the underlying LexicalAnalyzer
Throws:
inf.compilers.ExpressivenessException - if the input is not propositional
java.text.ParseException - if the KIF syntax is violated
java.io.IOException - if reading from the LexicalAnalyzer fails