ix.iface.domain
Class LTF_Parser
java.lang.Object
ix.iface.domain.DomainParser
ix.iface.domain.LTF_Parser
public class LTF_Parser
- extends DomainParser
A parser for domains described in a Lisp-like syntax.
The parser parses a file of refinement definitions to populate
a Domain.
In the syntax definitions below, all-upper-case names are literals
and lower- and mixed-case names are syntactic variables. Literals
should actually be written in lower case in domain definitions.
domain ::= {header | refinement | object-class | annotations | include}*
header ::= (DOMAIN domain-property*)
domain-property ::= (NAME string)
include ::= (INCLUDE file-name-or-URL-as-string)
refinement ::= (REFINEMENT name pattern clause*)
name ::= symbol | string
pattern ::= (item*)
item ::= number | symbol | string | pattern | variable
variable ::= ?symbol
clause ::= (VARIABLES variable-declaration*)
| (ISSUES issue*)
| (NODES node*)
| (ORDERINGS ordering*)
| (CONSTRAINTS constraint*)
| annotations
variable-declaration = variable
issue ::= (ISSUE pattern)
node ::= (node-id pattern)
ordering ::= ({node-end-ref | (node-end-ref*)}*)
constraint ::= (WORLD-STATE CONDITION pattern = value)
| (WORLD-STATE ACHIEVE pattern = value)
| (WORLD-STATE EFFECT pattern = value)
| (WORLD-STATE USE-FOR-EFFECT pattern = value)
| (COMPUTE [MULTIPLE-ANSWER] pattern = value)
| (ADVICE EXPANSION-REFINEMENT verb (symbol*))
| (TEMPORAL DURATION node-ref = time-window)
| (TEMPORAL BEFORE node-end-ref --> node-end-ref
= time-window)
(TEMPORAL WINDOW AT node-end-ref = time-window)
| (RESOURCE operation pattern = value)
| other-constraint
other-constraint ::= (type subtype pattern = value)
node-id ::= number | symbol | string
node-ref ::= node-id | SELF
node-end-ref ::= node-ref | B/node-ref | E/node-ref
value ::= item
verb, operation, type, subtype ::= symbol
time-window = duration | variable | min-duration [.. max-duration]
min-duration, max-duration ::= duration | variable
A duration has ISO 8601 syntax for days, hours, minutes, seconds
and milliseconds.
object-class ::= (OBJECT-CLASS class-name supers object-property*)
supers = (class-name*)
object-property ::= (property-name [class-name] [:SYNTAX value-syntax])
class-name ::= symbol | string
property-name ::= symbol | string
value-syntax ::= NUMBER | SYMBOL | STRING | LIST | OBJECT | DEFAULT
annotations :: = (ANNOTATIONS annotation*)
annotation ::= (aKey = aValue)
map ::= (MAP map-entry*)
map-entry ::= (aKey = aValue)
aKey and aValue can be anything the Lisp reader will accept.
aValue can also be a map. The word map must be written
"Map".
Note that an LTF_Parser can be used simply as a constraint-parser.
Like this:
import ix.iface.domain.LTF_Parser;
import ix.util.lisp.*;
LTF_Parser parser = new LTF_Parser();
String text = "(world-state condition (colour ?x) = red)";
Constraint c = parser.parseConstraint(Lisp.readFromString(text));
- See Also:
Domain
,
Duration
,
expandAllOrderings(LList)
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
sourceName
protected java.lang.String sourceName
lin
protected LispReader lin
lastRead
protected java.lang.Object lastRead
forceNumericNodeIds
protected boolean forceNumericNodeIds
badAnnotationsAreErrors
protected boolean badAnnotationsAreErrors
badAnnotations
protected java.util.Set badAnnotations
otherConstraints
protected java.util.Set otherConstraints
useConditionTypes
protected boolean useConditionTypes
parsers
protected MatchTable parsers
LTF_Parser
public LTF_Parser(java.lang.String filename)
throws java.io.FileNotFoundException
- Throws:
java.io.FileNotFoundException
LTF_Parser
public LTF_Parser(java.io.File file)
throws java.io.FileNotFoundException
- Throws:
java.io.FileNotFoundException
LTF_Parser
public LTF_Parser(java.net.URL url)
throws java.io.IOException
- Throws:
java.io.IOException
LTF_Parser
public LTF_Parser()
readDomain
public Domain readDomain()
- Specified by:
readDomain
in class DomainParser
readDomain
public Domain readDomain(Domain dom)
- Specified by:
readDomain
in class DomainParser
do_readDomain
protected void do_readDomain(Domain dom)
syntaxError
protected SyntaxException syntaxError(java.lang.String message)
theCons
protected static Cons theCons(java.lang.Object o)
theLList
protected static LList theLList(java.lang.Object o)
theSymbol
protected static Symbol theSymbol(java.lang.Object o)
theString
protected static java.lang.String theString(java.lang.Object o)
theName
protected static java.lang.String theName(java.lang.Object o)
theNodeId
protected static Name theNodeId(java.lang.Object o)
thePlainNodeId
protected Name thePlainNodeId(java.lang.Object o)
theNodeEndRef
protected NodeEndRef theNodeEndRef(Name nodeId,
End defaultEnd)
processDomainHeader
void processDomainHeader(Domain dom,
LList header)
makeRefinement
public Refinement makeRefinement(LList def)
makeVarDcls
public ix.icore.domain.ListOfVariableDeclaration makeVarDcls(LList items)
makeNodes
public ix.icore.domain.ListOfNodeSpec makeNodes(LList items)
makeOrderings
public ix.icore.domain.ListOfOrdering makeOrderings(LList items)
makeConstraints
public ix.icore.domain.ListOfConstraint makeConstraints(LList items)
makeIssues
public ix.icore.ListOfIssue makeIssues(LList items)
useNumericNodeIds
Refinement useNumericNodeIds(Refinement r)
makeNumericIdMap
java.util.Map makeNumericIdMap(ix.icore.domain.ListOfNodeSpec nodes)
expandAllOrderings
public static LList expandAllOrderings(LList orderings)
- Expands a list of orderings into a list of simple orderings.
Each simple ordering is a pair of node ids: (before after).
Each ordering is a list representing a sequence. Consider
adjacent elements A and B in such a list. Each node in A is
linked before each node in B. For example, (1 (2 3) 4) is
equivalent to the four separate lists (1 2), (1 3), (2 4), (3 4).
expandOrdering
public static LList expandOrdering(LList ordering)
expandOrderPair
static LList expandOrderPair(java.lang.Object left,
java.lang.Object right)
ensureList
static LList ensureList(java.lang.Object a)
parseConstraint
public Constraint parseConstraint(java.lang.Object spec)
getConstraintParsers
public MatchTable getConstraintParsers()
addConstraintParsers
protected void addConstraintParsers()
makeObjectClass
ObjectClass makeObjectClass(LList def)
makeSuperNames
ix.util.lisp.ListOfSymbol makeSuperNames(LList names)
makeObjectProperties
ix.icore.domain.ListOfObjectProperty makeObjectProperties(LList props)
makeObjectProperty
ObjectProperty makeObjectProperty(LList spec)
makeAnnotations
java.util.Map makeAnnotations(LList def)
makeMap
java.util.Map makeMap(LList def)
isMapSyntax
boolean isMapSyntax(java.lang.Object obj)
badAnnotation
void badAnnotation(LList kvPair)
doInclude
void doInclude(LList form)
throws java.io.IOException
- Throws:
java.io.IOException
defaultedIncludeURL
java.net.URL defaultedIncludeURL(java.lang.String name)
throws java.net.MalformedURLException
- Throws:
java.net.MalformedURLException