Building Parsers with Java

sjm.engine
Class Rule

java.lang.Object
  |
  +--sjm.engine.Rule
Direct Known Subclasses:
DynamicRule

public class Rule
extends java.lang.Object
implements Axiom

A Rule represents a logic statement that a structure is true if a following series of other structures are true.

For example,

     bachelor(X) :- male(X), unmarried(X);
 

is a logical rule.

A rule can make a provable version of itself, a DynamicRule, that is a essentially a copy of the structures in the rule, with a new scope and with a program to consult for other rules.


Field Summary
protected  Structure[] structures
           
 
Constructor Summary
Rule(Structure s)
          Construct a one-structure rule from the given structure.
Rule(Structure[] structures)
          Construct rule from the given structures.
 
Method Summary
 DynamicAxiom dynamicAxiom(AxiomSource as)
          Return a provable version of this rule.
 boolean equals(java.lang.Object o)
          Returns true if the supplied object is an equivalent rule.
 Structure head()
          Return the first structure in this rule.
 java.lang.String toString()
          Returns a string representation of this rule.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

structures

protected Structure[] structures
Constructor Detail

Rule

public Rule(Structure[] structures)
Construct rule from the given structures.
Parameters:
Structure[] - the structures that make up this rule.

Rule

public Rule(Structure s)
Construct a one-structure rule from the given structure.
Parameters:
Structure - the structure that makes up this rule.
Method Detail

dynamicAxiom

public DynamicAxiom dynamicAxiom(AxiomSource as)
Return a provable version of this rule.
Specified by:
dynamicAxiom in interface Axiom
Returns:
a provable version of this rule

equals

public boolean equals(java.lang.Object o)
Returns true if the supplied object is an equivalent rule.
Overrides:
equals in class java.lang.Object
Parameters:
object - the object to compare
Returns:
true, if the supplied object's structures equal this rule's structures

head

public Structure head()
Return the first structure in this rule.
Specified by:
head in interface Axiom
Returns:
the first structure in this rule

toString

public java.lang.String toString()
Returns a string representation of this rule.
Overrides:
toString in class java.lang.Object
Returns:
a string representation of this rule.

by Steve Metsker