ix.iface.domain
Class LTF_Parser

java.lang.Object
  extended by ix.iface.domain.DomainParser
      extended by ix.iface.domain.LTF_Parser
All Implemented Interfaces:
LTF_Symbols

public class LTF_Parser
extends DomainParser
implements LTF_Symbols

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 EFFECT pattern = value)
                |  (COMPUTE [MULTIPLE-ANSWER] pattern = value)
                |  (ADVICE EXPANSION-REFINEMENT verb (symbol*))
                |  (TEMPORAL DURATION SELF = min-duration .. max-duration)
                |  (RESOURCE operation pattern = value)
                |  other-constraint
    other-constraint ::= (type subtype pattern = value)
    node-id ::= number | symbol | string
    node-end-ref ::= node-id | B/node-id | E/node-id
    value ::= item
    verb, operation, type, subtype ::= symbol
    min-duration, max-duration ::= duration
    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".
 

See Also:
Domain, Duration, expandAllOrderings(LList)

Nested Class Summary
static class LTF_Parser.ConstraintParser
           
 
Nested classes/interfaces inherited from class ix.iface.domain.DomainParser
DomainParser.DomainParserWrapper
 
Field Summary
protected  java.util.Set badAnnotations
           
protected  boolean badAnnotationsAreErrors
           
protected  boolean forceNumericNodeIds
           
protected  java.lang.Object lastRead
           
protected  LispReader lin
           
protected  java.util.Set otherConstraints
           
protected  MatchTable parsers
           
protected  java.lang.String sourceName
           
 
Fields inherited from interface ix.iface.domain.LTF_Symbols
K_SYNTAX, Q_MAX, Q_MIN, Q_PATTERN, Q_VALUE, S_ANNOTATIONS, S_CONSTRAINTS, S_DOMAIN, S_INCLUDE, S_ISSUE, S_ISSUES, S_MAP, S_NAME, S_NODES, S_OBJECT_CLASS, S_ORDERINGS, S_REFINEMENT, S_SELF, S_VARIABLES
 
Constructor Summary
LTF_Parser()
           
LTF_Parser(java.io.File file)
           
LTF_Parser(java.lang.String filename)
           
LTF_Parser(java.net.URL url)
           
 
Method Summary
protected  void addConstraintParsers()
           
protected  void do_readDomain(Domain dom)
           
static LList expandAllOrderings(LList orderings)
          Expands a list of orderings into a list of simple orderings.
static LList expandOrdering(LList ordering)
           
 MatchTable getConstraintParsers()
           
 ix.icore.domain.ListOfConstraint makeConstraints(LList items)
           
 ix.icore.ListOfIssue makeIssues(LList items)
           
 ix.icore.domain.ListOfNodeSpec makeNodes(LList items)
           
 ix.icore.domain.ListOfOrdering makeOrderings(LList items)
           
 Refinement makeRefinement(LList def)
           
 ix.icore.domain.ListOfVariableDeclaration makeVarDcls(LList items)
           
 Constraint parseConstraint(java.lang.Object spec)
           
 Domain readDomain()
           
 Domain readDomain(Domain dom)
           
protected  SyntaxException syntaxError(java.lang.String message)
           
protected static Cons theCons(java.lang.Object o)
           
protected static LList theLList(java.lang.Object o)
           
protected static java.lang.String theName(java.lang.Object o)
           
protected static NodeEndRef theNodeEndRef(Name nodeId, End defaultEnd)
           
protected static Name theNodeId(java.lang.Object o)
           
protected static java.lang.String theString(java.lang.Object o)
           
protected static Symbol theSymbol(java.lang.Object o)
           
 
Methods inherited from class ix.iface.domain.DomainParser
getLibraryDirectory, loadDomain, makeParser
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

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

parsers

protected MatchTable parsers
Constructor Detail

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()
Method Detail

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)

theNodeEndRef

protected static NodeEndRef theNodeEndRef(Name nodeId,
                                          End defaultEnd)

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)

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)

parseConstraint

public Constraint parseConstraint(java.lang.Object spec)

getConstraintParsers

public MatchTable getConstraintParsers()

addConstraintParsers

protected void addConstraintParsers()