Building Parsers with Java

sjm.engine
Class ConsultingStructure

java.lang.Object
  |
  +--sjm.engine.Structure
        |
        +--sjm.engine.ConsultingStructure

public class ConsultingStructure
extends Structure

A ConsultingStructure is structure that can prove itself against an axiom source supplied with the constructor.

When a rule creates a dynamic version of itself, a normal structure will create a ConsultingStructure counterpart that uses the rule's scope, and that consults a given axiom source (such as a Program).

The primary behavior that a ConsultingStructure adds is the ability to prove itself.


Field Summary
protected  AxiomEnumeration axioms
           
protected  Unification currentUnification
           
protected  DynamicRule resolvent
           
protected  AxiomSource source
           
 
Fields inherited from class sjm.engine.Structure
emptyList, functor, terms
 
Constructor Summary
protected ConsultingStructure(AxiomSource source, java.lang.Object functor, Term[] terms)
           
 
Method Summary
protected  AxiomEnumeration axioms()
           
 boolean canFindNextProof()
          Tests if this structure can find another proof, and, if so, sets this structure's variables to the values that make the proof true.
protected  boolean canUnify()
          Return true if this structure can unify with another rule in the program.
protected  void unbind()
          Release the variable bindings that the last unification produced.
 
Methods inherited from class sjm.engine.Structure
arity, copyForProof, equals, eval, functorAndArityEquals, headAndTail, isList, list, list, list, listTailString, listTermsToString, terms, toString, unify, unify, unify, variables
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

source

protected AxiomSource source

axioms

protected AxiomEnumeration axioms

currentUnification

protected Unification currentUnification

resolvent

protected DynamicRule resolvent
Constructor Detail

ConsultingStructure

protected ConsultingStructure(AxiomSource source,
                              java.lang.Object functor,
                              Term[] terms)
Method Detail

axioms

protected AxiomEnumeration axioms()

canFindNextProof

public boolean canFindNextProof()
Tests if this structure can find another proof, and, if so, sets this structure's variables to the values that make the proof true.
Overrides:
canFindNextProof in class Structure
Returns:
true if this structure can find another proof.

canUnify

protected boolean canUnify()
Return true if this structure can unify with another rule in the program.

A consulting structure proves itself true by unifying with the head of a rule in a program, and then asking the tail of that rule to prove itself. Unification is a kind of matching. Two structures unify if they have equal functors, and the terms all unify. A variable unifies with a structure simply by setting its instantiation to be the structure.

For example, the following structures can unify:

     starred(jamesCagney, Title, Year)
     starred(jamesCagney, "Yankee Doodle Dandy", 1942)
 
When these structures unify, the variable Title will bind itself to "Yankee Doodle Dandy", and Year will bind to 1942. To be more specific, Title will bind to the atom whose functor is "Yankee Doodle Dandy". Year will bind to the atom whose functor is the number 1942.
Returns:
true, if this structure can unify with an axiom in the axiom source

unbind

protected void unbind()
Release the variable bindings that the last unification produced.

by Steve Metsker