|
Building Parsers with Java | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--sjm.engine.Structure
|
+--sjm.engine.Fact
A Fact is a Structure that contains only other Facts.
For example,
Fact s = new Fact(
"starred",
new Fact[]{
new Fact("James Cagney"),
new Fact("Yankee Doodle Dandy")});
The Fact class offers several convenience constructors. For
example, you can create an identical fact with:
Fact s = new Fact(
"starred", "James Cagney", "Yankee Doodle Dandy");
or with:
Fact s = new Fact(
"starred",
new Object[]{
"James Cagney", "Yankee Doodle Dandy"});
Since they do not contain variables, Facts do not need to
copy themselves when they provide a "copy" for a proof.
They also avoid copying when then provide a dynamic
axiom.
| Field Summary | |
protected static DynamicRule |
resolvent
|
| Fields inherited from class sjm.engine.Structure |
emptyList,
functor,
terms |
| Constructor Summary | |
Fact(java.lang.Object functor)
Contructs a fact from the specified object. |
|
Fact(java.lang.Object functor,
Fact[] terms)
Constructs a fact with the specified functor and facts. |
|
Fact(java.lang.Object functor,
java.lang.Object o)
A convenience, equivalent to new Fact(functor, new
Object[]{o}). |
|
Fact(java.lang.Object functor,
java.lang.Object[] objects)
Constructs a fact with the specified functor, and with terms that are atoms wrapped around the supplied objects. |
|
Fact(java.lang.Object functor,
java.lang.Object o1,
java.lang.Object o2)
A convenience, equivalent to new Fact(functor, new
Object[]{o1, o2}). |
|
Fact(java.lang.Object functor,
Term[] objects)
Although "public", this method is not for public use. |
|
| Method Summary | |
Term |
copyForProof(AxiomSource ignored,
Scope ignored2)
Returns this fact. |
DynamicAxiom |
dynamicAxiom(AxiomSource ignored)
Returns this fact. |
protected static Fact[] |
facts(java.lang.Object[] objects)
|
Structure |
head()
Returns this fact. |
DynamicRule |
resolvent()
Returns an empty resolvent |
Unification |
unify(Fact f)
A speedier version of unify(Structure s). |
| Methods inherited from class sjm.engine.Structure |
arity,
canFindNextProof,
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 |
protected static final DynamicRule resolvent
| Constructor Detail |
public Fact(java.lang.Object functor)
Object - the functor for this fact
public Fact(java.lang.Object functor,
java.lang.Object[] objects)
Object - the functor of the structureObject[] - the objects to convert into atoms
and use as the terms of this fact
public Fact(java.lang.Object functor,
Fact[] terms)
Object - the functor of the structureTerm[] - the terms of this fact, which can only
be other facts
public Fact(java.lang.Object functor,
Term[] objects)
Without this constructor, or if this constructor were private,
new Fact(
"starred",
new Term[]{new Fact("Cagney", "Yankee Doodle Dandy")})
would match the signature on Fact(Object, Object[])
, which is not what we want. This would wrap each
fact in another fact.
Allowing this constructor gives the appearance of allowing Facts with any kind of terms, including variables, which are verboten.
public Fact(java.lang.Object functor,
java.lang.Object o)
new Fact(functor, new
Object[]{o}).Object - the functor of the structureObject - the object to convert to an atom
and use as the term of this fact
public Fact(java.lang.Object functor,
java.lang.Object o1,
java.lang.Object o2)
new Fact(functor, new
Object[]{o1, o2}).Object - the functor of the structureObject - an object to convert to an atom
and use as the first term of this factObject - an object to convert to an atom
and use as the second term of this fact| Method Detail |
public Term copyForProof(AxiomSource ignored,
Scope ignored2)
public DynamicAxiom dynamicAxiom(AxiomSource ignored)
protected static Fact[] facts(java.lang.Object[] objects)
public Structure head()
public DynamicRule resolvent()
public Unification unify(Fact f)
unify(Structure s).
|
by Steve Metsker | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||