ai.planning.strips
Class PddlProblemAdaptor

java.lang.Object
  extended by ai.planning.strips.PddlProblemAdaptor
All Implemented Interfaces:
inf.compilers.SyntaxAdaptor<Problem>

public class PddlProblemAdaptor
extends java.lang.Object
implements inf.compilers.SyntaxAdaptor<Problem>


Field Summary
protected static inf.compilers.LexicalAnalyzer.TokenType closebracketTT
          the token types used
protected static inf.compilers.LexicalAnalyzer.TokenType domainTT
          the token types used
protected static inf.compilers.LexicalAnalyzer.TokenType goalTT
          the token types used
protected static inf.compilers.LexicalAnalyzer.TokenType ignorableTT
          the token types used
protected static inf.compilers.LexicalAnalyzer.TokenType initTT
          the token types used
protected static inf.compilers.LexicalAnalyzer.TokenType objectsTT
          the token types used
protected static inf.compilers.LexicalAnalyzer.TokenType openbracketTT
          the token types used
protected static inf.compilers.LexicalAnalyzer.TokenType problemTT
          the token types used
protected  java.util.Properties props
          the properties used for reading and writing
protected  inf.compilers.LexicalAnalyzer scanner
          the lexical analyzer used for tokenizing the input
 
Constructor Summary
PddlProblemAdaptor()
           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  PddlDomainAdaptor clone()
           
 java.lang.Class<Problem> 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.
protected static Domain parseDomainNB(inf.compilers.LexicalAnalyzer scanner, java.util.Properties props)
           ::= ":domain" next token must be closing bracket!
protected static Goal parseGoalNB(inf.compilers.LexicalAnalyzer scanner, java.util.Properties props, PddlDomainAdaptor.ParsingContext context)
           ::= ":goal" '(' ')' next token must be closing bracket!
protected static java.util.Set<ai.krr.fol.Atom> parseInitNB(inf.compilers.LexicalAnalyzer scanner, java.util.Properties props, PddlDomainAdaptor.ParsingContext context)
           ::= ":init" + next token must be closing bracket!
protected static java.util.Set<ai.krr.ontologies.Instance> parseObjectsNB(inf.compilers.LexicalAnalyzer scanner, java.util.Properties props, PddlDomainAdaptor.ParsingContext context)
           ::= ":objects" * next token must be closing bracket!
protected  Problem parseProblem()
           
protected static ai.krr.NamedSymbol parseProblemName(inf.compilers.LexicalAnalyzer scanner, java.util.Properties props)
           ::= '(' problem ')'
 void prettyPrint(int indent, Problem problem, java.io.Writer w)
           This function takes a logical Sentence which is a Java Object in the internal representation, and writes it to the given Writer as a string conforming to the KIF syntax.
static void prettyPrintAtoms(int indent, java.util.Iterator<ai.krr.fol.Atom> atoms, java.io.Writer w, java.util.Properties props)
           
static void prettyPrintDomain(int indent, Domain domain, java.io.Writer w, java.util.Properties props)
           
static void prettyPrintInitialState(int indent, WorldState state, java.io.Writer w, java.util.Properties props)
           
static void prettyPrintProblem(int indent, Problem problem, java.io.Writer w, java.util.Properties props)
           
 Problem read(java.io.Reader r)
           This function attempts to parse characters from the given Reader until a Sentence 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(Problem problem, java.io.Writer w)
           This function takes a logical Sentence which is a Java Object in the internal representation, and writes it to the given Writer as a string conforming to the KIF syntax.
static void writeAtoms(java.util.Iterator<ai.krr.fol.Atom> atoms, java.io.Writer w, java.util.Properties props)
           
static void writeDomain(Domain domain, java.io.Writer w, java.util.Properties props)
           
static void writeInitialState(WorldState state, java.io.Writer w, java.util.Properties props)
           
static void writeProblem(Problem problem, java.io.Writer w, java.util.Properties props)
           
 
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


openbracketTT

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


closebracketTT

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


problemTT

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


domainTT

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


objectsTT

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


initTT

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


goalTT

protected static inf.compilers.LexicalAnalyzer.TokenType goalTT
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

PddlProblemAdaptor

public PddlProblemAdaptor()

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 PddlDomainAdaptor clone()
                           throws java.lang.CloneNotSupportedException
Overrides:
clone in class java.lang.Object
Throws:
java.lang.CloneNotSupportedException

getInternalClass

public java.lang.Class<Problem> 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<Problem>
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<Problem>
Returns:
the name of the language adapted to

write

public void write(Problem problem,
                  java.io.Writer w)
           throws inf.compilers.ExpressivenessException,
                  java.io.IOException

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

Specified by:
write in interface inf.compilers.SyntaxAdaptor<Problem>
Parameters:
stmt - a Sentence 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 statement
java.io.IOException - if writing to the given Writer fails

prettyPrint

public void prettyPrint(int indent,
                        Problem problem,
                        java.io.Writer w)
                 throws inf.compilers.ExpressivenessException,
                        java.io.IOException

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

Specified by:
prettyPrint in interface inf.compilers.SyntaxAdaptor<Problem>
Parameters:
indent - the amount of indentation for the first line
stmt - a Sentence 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 statement
java.io.IOException - if writing to the given Writer fails

read

public Problem 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 a Sentence that represents an object in the internal representation has been parsed.

Specified by:
read in interface inf.compilers.SyntaxAdaptor<Problem>
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 statement
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<Problem>
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<Problem>
Parameters:
key - the key with which the value is associated
value - the associated value

writeProblem

public static void writeProblem(Problem problem,
                                java.io.Writer w,
                                java.util.Properties props)
                         throws inf.compilers.ExpressivenessException,
                                java.io.IOException
Throws:
inf.compilers.ExpressivenessException
java.io.IOException

prettyPrintProblem

public static void prettyPrintProblem(int indent,
                                      Problem problem,
                                      java.io.Writer w,
                                      java.util.Properties props)
                               throws inf.compilers.ExpressivenessException,
                                      java.io.IOException
Throws:
inf.compilers.ExpressivenessException
java.io.IOException

writeDomain

public static void writeDomain(Domain domain,
                               java.io.Writer w,
                               java.util.Properties props)
                        throws inf.compilers.ExpressivenessException,
                               java.io.IOException
Throws:
inf.compilers.ExpressivenessException
java.io.IOException

prettyPrintDomain

public static void prettyPrintDomain(int indent,
                                     Domain domain,
                                     java.io.Writer w,
                                     java.util.Properties props)
                              throws inf.compilers.ExpressivenessException,
                                     java.io.IOException
Throws:
inf.compilers.ExpressivenessException
java.io.IOException

writeInitialState

public static void writeInitialState(WorldState state,
                                     java.io.Writer w,
                                     java.util.Properties props)
                              throws inf.compilers.ExpressivenessException,
                                     java.io.IOException
Throws:
inf.compilers.ExpressivenessException
java.io.IOException

prettyPrintInitialState

public static void prettyPrintInitialState(int indent,
                                           WorldState state,
                                           java.io.Writer w,
                                           java.util.Properties props)
                                    throws inf.compilers.ExpressivenessException,
                                           java.io.IOException
Throws:
inf.compilers.ExpressivenessException
java.io.IOException

writeAtoms

public static void writeAtoms(java.util.Iterator<ai.krr.fol.Atom> atoms,
                              java.io.Writer w,
                              java.util.Properties props)
                       throws inf.compilers.ExpressivenessException,
                              java.io.IOException
Throws:
inf.compilers.ExpressivenessException
java.io.IOException

prettyPrintAtoms

public static void prettyPrintAtoms(int indent,
                                    java.util.Iterator<ai.krr.fol.Atom> atoms,
                                    java.io.Writer w,
                                    java.util.Properties props)
                             throws inf.compilers.ExpressivenessException,
                                    java.io.IOException
Throws:
inf.compilers.ExpressivenessException
java.io.IOException

parseProblem

protected Problem parseProblem()
                        throws inf.compilers.ExpressivenessException,
                               java.text.ParseException,
                               java.io.IOException
Throws:
inf.compilers.ExpressivenessException
java.text.ParseException
java.io.IOException

parseProblemName

protected static ai.krr.NamedSymbol parseProblemName(inf.compilers.LexicalAnalyzer scanner,
                                                     java.util.Properties props)
                                              throws inf.compilers.ExpressivenessException,
                                                     java.text.ParseException,
                                                     java.io.IOException
::= '(' problem ')'

Parameters:
scanner - the LexicalAnalyzer from which tokens are parsed
props - the properties for parsing
context - declared requirements, extensions, variables, etc.
Returns:
the declared name for this Problem
Throws:
inf.compilers.ExpressivenessException
java.text.ParseException
java.io.IOException

parseDomainNB

protected static Domain parseDomainNB(inf.compilers.LexicalAnalyzer scanner,
                                      java.util.Properties props)
                               throws inf.compilers.ExpressivenessException,
                                      java.text.ParseException,
                                      java.io.IOException
::= ":domain" next token must be closing bracket!

Parameters:
scanner - the LexicalAnalyzer from which tokens are parsed
props - the properties for parsing
context - declared requirements, extensions, variables, etc.
Returns:
the set of declared instances
Throws:
inf.compilers.ExpressivenessException
java.text.ParseException
java.io.IOException

parseObjectsNB

protected static java.util.Set<ai.krr.ontologies.Instance> parseObjectsNB(inf.compilers.LexicalAnalyzer scanner,
                                                                          java.util.Properties props,
                                                                          PddlDomainAdaptor.ParsingContext context)
                                                                   throws inf.compilers.ExpressivenessException,
                                                                          java.text.ParseException,
                                                                          java.io.IOException
::= ":objects" * next token must be closing bracket!

Parameters:
scanner - the LexicalAnalyzer from which tokens are parsed
props - the properties for parsing
context - declared requirements, extensions, variables, etc.
Returns:
the set of declared instances
Throws:
inf.compilers.ExpressivenessException
java.text.ParseException
java.io.IOException

parseInitNB

protected static java.util.Set<ai.krr.fol.Atom> parseInitNB(inf.compilers.LexicalAnalyzer scanner,
                                                            java.util.Properties props,
                                                            PddlDomainAdaptor.ParsingContext context)
                                                     throws inf.compilers.ExpressivenessException,
                                                            java.text.ParseException,
                                                            java.io.IOException
::= ":init" + next token must be closing bracket!

Parameters:
scanner - the LexicalAnalyzer from which tokens are parsed
props - the properties for parsing
context - declared requirements, extensions, variables, etc.
Returns:
the set of declared instances
Throws:
inf.compilers.ExpressivenessException
java.text.ParseException
java.io.IOException

parseGoalNB

protected static Goal parseGoalNB(inf.compilers.LexicalAnalyzer scanner,
                                  java.util.Properties props,
                                  PddlDomainAdaptor.ParsingContext context)
                           throws inf.compilers.ExpressivenessException,
                                  java.text.ParseException,
                                  java.io.IOException
::= ":goal" '(' ')' next token must be closing bracket!

Parameters:
scanner - the LexicalAnalyzer from which tokens are parsed
props - the properties for parsing
context - declared requirements, extensions, variables, etc.
Returns:
the set of declared instances
Throws:
inf.compilers.ExpressivenessException
java.text.ParseException
java.io.IOException