|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object ai.planning.propositional.PplDomainAdaptor
public class PplDomainAdaptor
This class is an adaptor between the ai.planning.propositional.Domain class that can be used as an internal representation for planning domains and its external form as defined by the PPL (Propositional Planning Language) syntax as described below.
The syntax used here is a Lisp-like syntax in which every expression is a
list that is enclosed in brackets. For example, the definition of a domain is
a list consisting of the symbol define
followed by a list
specifying the domain name, followed by any number of lists defining
propositional planning operators. The list specifying the domain name must
consist of the symbol domain
followed by a name (another symbol)
which represents the name of the domain. This syntax can be described more
formally as follows:
<Domain> ::= '(' define <DomainName> <ActionType>* ')' <DomainName> ::= '(' domain <name> ')'
Each propositional planning operator is defined by a list beginning with the
keyword :action
followed by the symbol defining the name of the
operator. This may be followed by three further lists representing the
preconditions, delete-list, and add-list that define the operator. Note that
each of these lists is optional, although omitting all three results in a
rather useless action. Each of these lists is preceded by an appropriate
keyword and defined by a set of propositional atoms (symbols) given as the
content of the list. Formally, the syntax is as follows:
<ActionType> ::= '(' :action <name> [<Preconditions>] [<DeleteList>] [<AddList>] ')' <Preconditions> ::= :pre '(' <Atom>+ ')' <DeleteList> ::= :del '(' <Atom>+ ')' <AddList> ::= :add '(' <Atom>+ ')'
A number of properties can be used modify the behaviour of this
SyntaxAdaptor. Symbols are case-sensitive by default, which can be changed by
setting the property case-sensitive
to false
.
Similarly the property namespace-aware
determines whether
symbols are expected to belong to namespaces.
The remaining properties can be used to set the string used for a single indent (two spaces by default) and the maximal line width. Both of these properties are used for pretty-printing only.
property | possible values | default |
---|---|---|
case-sensitive | true, false | true |
namespace-aware | true, false | true |
indent-string | any string | " " |
line-width | positive int | 80 |
PplProblemAdaptor
Field Summary | |
---|---|
protected static inf.compilers.LexicalAnalyzer.TokenType |
actionTT
the token types used |
protected static inf.compilers.LexicalAnalyzer.TokenType |
addTT
the token types used |
protected static inf.compilers.LexicalAnalyzer.TokenType |
closebracketTT
the token types used |
protected static inf.compilers.LexicalAnalyzer.TokenType |
defineTT
the token types used |
protected static inf.compilers.LexicalAnalyzer.TokenType |
deleteTT
the token types used |
protected static inf.compilers.LexicalAnalyzer.TokenType |
domainTT
the token types used |
protected static inf.compilers.LexicalAnalyzer.TokenType |
ignorableTT
the token types used |
protected static inf.compilers.LexicalAnalyzer.TokenType |
openbracketTT
the token types used |
protected static inf.compilers.LexicalAnalyzer.TokenType |
precondsTT
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 | |
---|---|
PplDomainAdaptor()
This constructor creates a SyntaxAdaptor that can be used to read propositional planning domains and create a propositional Domain for it, or it can be used to write out a propositional Domain in the PPL syntax. |
Method Summary | |
---|---|
protected java.lang.Object |
clone()
This class does not support cloning and an Exception will be thrown if this method is called. |
java.lang.Class<Domain> |
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 ActionType |
parseActionTypeNB(inf.compilers.LexicalAnalyzer scanner,
java.util.Properties props)
This function reads tokens from the given LexicalAnalyzer and attempts to create an ActionType that corresponds to the parsed tokens. |
protected static Domain |
parseDomain(inf.compilers.LexicalAnalyzer scanner,
java.util.Properties props)
This function reads tokens from the given LexicalAnalyzer and attempts to create a propositional Domain that corresponds to the parsed tokens. |
void |
prettyPrint(int indent,
Domain domain,
java.io.Writer w)
This function takes a propositional Domain which is a Java Object in the internal representation, and writes it to the given Writer as a string conforming to the PPL syntax. |
protected static void |
prettyPrintActionType(int indent,
ActionType aType,
java.io.Writer w,
java.util.Properties props)
This function writes the given ActionType to the given Writer, using the given Properties. |
protected static int |
prettyPrintAtom(int indent,
int usedInLine,
int lineWidth,
ai.krr.propositions.Atom atom,
java.io.Writer w,
java.util.Properties props)
|
static void |
prettyPrintDomain(int indent,
Domain domain,
java.io.Writer w,
java.util.Properties props)
This function writes the given Domain to the given Writer, using the given Properties. |
Domain |
read(java.io.Reader r)
This function attempts to parse characters from the given Reader until a Domain 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(Domain domain,
java.io.Writer w)
This function takes a propositional Domain which is a Java Object in the internal representation, and writes it to the given Writer as a string conforming to the PPL syntax. |
protected static void |
writeActionType(ActionType aType,
java.io.Writer w,
java.util.Properties props)
This function writes the given ActionType to the given Writer, using the given Properties. |
static void |
writeDomain(Domain domain,
java.io.Writer w,
java.util.Properties props)
This function writes the given Domain to the given Writer, using the given Properties. |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static inf.compilers.LexicalAnalyzer.TokenType ignorableTT
protected static inf.compilers.LexicalAnalyzer.TokenType openbracketTT
protected static inf.compilers.LexicalAnalyzer.TokenType closebracketTT
protected static inf.compilers.LexicalAnalyzer.TokenType defineTT
protected static inf.compilers.LexicalAnalyzer.TokenType domainTT
protected static inf.compilers.LexicalAnalyzer.TokenType actionTT
protected static inf.compilers.LexicalAnalyzer.TokenType precondsTT
protected static inf.compilers.LexicalAnalyzer.TokenType addTT
protected static inf.compilers.LexicalAnalyzer.TokenType deleteTT
protected inf.compilers.LexicalAnalyzer scanner
protected java.util.Properties props
Constructor Detail |
---|
public PplDomainAdaptor()
This constructor creates a SyntaxAdaptor that can be used to read propositional planning domains and create a propositional Domain for it, or it can be used to write out a propositional Domain in the PPL syntax.
Method Detail |
---|
protected java.lang.Object clone() throws java.lang.CloneNotSupportedException
This class does not support cloning and an Exception will be thrown if this method is called.
clone
in class java.lang.Object
java.lang.CloneNotSupportedException
- will be thrownpublic java.lang.Class<Domain> getInternalClass()
This function returns the Class that holds the internal representation this adaptor translates to and from.
getInternalClass
in interface inf.compilers.SyntaxAdaptor<Domain>
public java.lang.String getSyntaxName()
This function returns the name that should identify the syntactical language that this adaptor translates to and from.
getSyntaxName
in interface inf.compilers.SyntaxAdaptor<Domain>
public void write(Domain domain, java.io.Writer w) throws inf.compilers.ExpressivenessException, java.io.IOException
This function takes a propositional Domain which is a Java Object in the internal representation, and writes it to the given Writer as a string conforming to the PPL syntax.
write
in interface inf.compilers.SyntaxAdaptor<Domain>
domain
- a Domain in the internal representationw
- the Writer to which the syntactical translation is written
inf.compilers.ExpressivenessException
- if the syntactical language cannot represent
the given Domain
java.io.IOException
- if writing to the given Writer failspublic void prettyPrint(int indent, Domain domain, java.io.Writer w) throws inf.compilers.ExpressivenessException, java.io.IOException
This function takes a propositional Domain which is a Java Object in the internal representation, and writes it to the given Writer as a string conforming to the PPL syntax.
prettyPrint
in interface inf.compilers.SyntaxAdaptor<Domain>
indent
- the amount of indentation for the first linedomain
- a Domain in the internal representationw
- the Writer to which the syntactical translation is written
inf.compilers.ExpressivenessException
- if the syntactical language cannot represent
the given Domain
java.io.IOException
- if writing to the given Writer failspublic Domain 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 Domain that represents an object in the internal representation has been parsed.
read
in interface inf.compilers.SyntaxAdaptor<Domain>
r
- the Reader from which the representation is to be parsed
inf.compilers.ExpressivenessException
- if the internal representation class is not
expressive enough for the given domain
java.text.ParseException
- if there is a syntax error in the given string
java.io.IOException
- if reading from the Reader failspublic java.lang.String getProperty(java.lang.String key)
This function gets the property that is associated with the given key. Note that the key should not be null.
getProperty
in interface inf.compilers.SyntaxAdaptor<Domain>
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.
setProperty
in interface inf.compilers.SyntaxAdaptor<Domain>
key
- the key with which the value is associatedvalue
- the associated valuepublic static void writeDomain(Domain domain, java.io.Writer w, java.util.Properties props) throws inf.compilers.ExpressivenessException, java.io.IOException
This function writes the given Domain to the given Writer, using the given Properties. The syntax used is as follows:
<Domain> ::= '(' define <DomainName> <ActionType>* ')' <DomainName> ::= '(' domain <name> ')'
domain
- the Domain to be writtenw
- the Writer to which the character representation is writtenprops
- the Properties determining the exact syntax
inf.compilers.ExpressivenessException
- if the syntactical language cannot represent
the given Domain
java.io.IOException
- if writing to the given Writer failspublic static void prettyPrintDomain(int indent, Domain domain, java.io.Writer w, java.util.Properties props) throws inf.compilers.ExpressivenessException, java.io.IOException
This function writes the given Domain to the given Writer, using the given Properties. The syntax is the same as for writing.
indent
- the amount of indentation for the first linedomain
- the Domain to be writtenw
- the Writer to which the character representation is writtenprops
- the Properties determining the exact syntax
inf.compilers.ExpressivenessException
- if the syntactical language cannot represent
the given Domain
java.io.IOException
- if writing to the given Writer failsprotected static void writeActionType(ActionType aType, java.io.Writer w, java.util.Properties props) throws inf.compilers.ExpressivenessException, java.io.IOException
This function writes the given ActionType to the given Writer, using the given Properties. The syntax used is as follows:
<ActionType> ::= '(' :action <name> [<Preconditions>] [<DeleteList>] [<AddList>] ')' <Preconditions> ::= :pre '(' <Atom>+ ')' <DeleteList> ::= :del '(' <Atom>+ ')' <AddList> ::= :add '(' <Atom>+ ')'
aType
- the ActionType to be writtenw
- the Writer to which the character representation is writtenprops
- the Properties determining the exact syntax
inf.compilers.ExpressivenessException
- if the syntactical language cannot represent
the given Domain
java.io.IOException
- if writing to the given Writer failsprotected static void prettyPrintActionType(int indent, ActionType aType, java.io.Writer w, java.util.Properties props) throws inf.compilers.ExpressivenessException, java.io.IOException
This function writes the given ActionType to the given Writer, using the given Properties. The syntax is the same as for writing.
indent
- the indent of the first lineaType
- the ActionType to be written to the given Writerw
- the Writer to which the character representation is writtenprops
- the Properties determining the exact syntax
inf.compilers.ExpressivenessException
- if the syntactical language cannot represent
the given Domain
java.io.IOException
- if writing to the given Writer failsprotected static int prettyPrintAtom(int indent, int usedInLine, int lineWidth, ai.krr.propositions.Atom atom, java.io.Writer w, java.util.Properties props) throws inf.compilers.ExpressivenessException, java.io.IOException
inf.compilers.ExpressivenessException
java.io.IOException
protected static Domain parseDomain(inf.compilers.LexicalAnalyzer scanner, java.util.Properties props) throws inf.compilers.ExpressivenessException, java.text.ParseException, java.io.IOException
This function reads tokens from the given LexicalAnalyzer and attempts to create a propositional Domain that corresponds to the parsed tokens. The given properties determine the exact syntax.
<Domain> ::= '(' define <DomainName> <ActionType>* ')' <DomainName> ::= '(' domain <name> ')' <ActionType> ::= '(' <ActionTypeNB> ')'
scanner
- the LexicalAnalyzer from which tokens are parsedprops
- the properties for parsing
inf.compilers.ExpressivenessException
- if the syntactical language uses features
not supported by the internal representation
java.text.ParseException
- if the input contains a syntactical error
java.io.IOException
- if reading from the Reader failsprotected static ActionType parseActionTypeNB(inf.compilers.LexicalAnalyzer scanner, java.util.Properties props) throws inf.compilers.ExpressivenessException, java.text.ParseException, java.io.IOException
This function reads tokens from the given LexicalAnalyzer and attempts to create an ActionType that corresponds to the parsed tokens. The given properties determine the exact syntax. Note that any brackets that surround the operator definition must be parsed at the level of the calling function.
<ActionTypeNB> ::= :action <name> [ <Preconditions> ] [ <DeleteList> ] [ <AddListB> ] <Preconditions> ::= :pre '(' <Atom>+ ')' <DeleteList> ::= :del '(' <Atom>+ ')' <AddList> ::= :add '(' <Atom>+ ')'
scanner
- the LexicalAnalyzer from which tokens are parsedprops
- the properties for parsing
inf.compilers.ExpressivenessException
- if the syntactical language uses features
not supported by the internal representation
java.text.ParseException
- if the input contains a syntactical error
java.io.IOException
- if reading from the Reader fails
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |