ix.iface.domain
Class LTF_Parser.ConstraintParser

java.lang.Object
  extended by ix.util.match.MatchCase
      extended by ix.iface.domain.LTF_Parser.ConstraintParser
Direct Known Subclasses:
LTF_Parser.AdviceParser, LTF_Parser.ComputeParser, LTF_Parser.MultipleAnswerComputeParser, LTF_Parser.OtherConstraintParser, LTF_Parser.ResourceConstraintParser, LTF_Parser.TemporalConstraintParser, LTF_Parser.WorldStateConstraintParser
Enclosing class:
LTF_Parser

public abstract static class LTF_Parser.ConstraintParser
extends MatchCase

Used to parse a constraint and also, via the makeTemplate method, to describe the syntax.


Field Summary
 
Fields inherited from class ix.util.match.MatchCase
pattern
 
Constructor Summary
LTF_Parser.ConstraintParser(java.lang.String pat)
          Constructs a parser for constraints that match the given pattern.
 
Method Summary
 java.lang.Object ifSelected(java.lang.Object spec, java.lang.Object match)
          Just calls makeConstraint.
abstract  Constraint makeConstraint(LList spec, MatchEnv env)
          Construct a constraint based on the spec and any bindings in the MatchEnv.
abstract  Constraint makeTemplate()
          Returns a constraint that represents the syntax of the constraints handled by this constraint-parser.
 java.lang.Object tryMatch(java.lang.Object spec)
          Matches this parser's pattern against the spec by calling SimpleMatcher.match(Object, Object).
 
Methods inherited from class ix.util.match.MatchCase
getPattern
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LTF_Parser.ConstraintParser

LTF_Parser.ConstraintParser(java.lang.String pat)
Constructs a parser for constraints that match the given pattern. For convenience, the pattern is given as a string and turned into the pattern that's actually used by calling Lisp.readFromString(String).

Method Detail

tryMatch

public java.lang.Object tryMatch(java.lang.Object spec)
Matches this parser's pattern against the spec by calling SimpleMatcher.match(Object, Object). The 'spec' is the piece of LTF source code that's meant to represent a constraint. If the match is successful, ifSelected will then be called, passing the spec and the MatchEnv that SimpleMatcher returned. ifSelected will then call makeConstraint.

Specified by:
tryMatch in class MatchCase

ifSelected

public java.lang.Object ifSelected(java.lang.Object spec,
                                   java.lang.Object match)
Just calls makeConstraint.

Overrides:
ifSelected in class MatchCase

makeConstraint

public abstract Constraint makeConstraint(LList spec,
                                          MatchEnv env)
Construct a constraint based on the spec and any bindings in the MatchEnv. The env was produced by calling this constraint-parser's tryMatch method. The spec came from the LTF source.


makeTemplate

public abstract Constraint makeTemplate()
Returns a constraint that represents the syntax of the constraints handled by this constraint-parser.