You can subscribe to this list here.
2001 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
(126) |
Nov
(168) |
Dec
(142) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2002 |
Jan
(118) |
Feb
(90) |
Mar
(49) |
Apr
(108) |
May
(47) |
Jun
(45) |
Jul
(48) |
Aug
(9) |
Sep
(45) |
Oct
(58) |
Nov
(64) |
Dec
(47) |
2003 |
Jan
(16) |
Feb
(48) |
Mar
(80) |
Apr
(35) |
May
(31) |
Jun
(37) |
Jul
(18) |
Aug
(26) |
Sep
|
Oct
|
Nov
(24) |
Dec
(9) |
2004 |
Jan
(5) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: blackh <gra...@li...> - 2001-10-03 10:55:12
|
blackh Wed Oct 3 03:55:11 2001 EDT Added files: /proto1 animal.xml Modified files: /proto1 Engine.cpp RuleBase.cpp Log: The animal example works now. Index: proto1/Engine.cpp diff -u proto1/Engine.cpp:1.10 proto1/Engine.cpp:1.11 --- proto1/Engine.cpp:1.10 Wed Oct 3 03:41:54 2001 +++ proto1/Engine.cpp Wed Oct 3 03:55:11 2001 @@ -1,4 +1,4 @@ -// $Id: Engine.cpp,v 1.10 2001/10/03 10:41:54 blackh Exp $ +// $Id: Engine.cpp,v 1.11 2001/10/03 10:55:11 blackh Exp $ #include "Engine.h" @@ -89,7 +89,6 @@ void DomainPattern::process(Domain& domain, RuleState& ruleState, Fact fact, FactSeq& tagsTraversed, int debugIndent) { - cout << "domain=" << domain << endl; int domainIndex = domain.getDomainIndex(); domains[domainIndex]->process(domain, ruleState, fact, tagsTraversed, debugIndent+1); @@ -185,19 +184,10 @@ void FactPattern::process(Domain& domain, RuleState& ruleState, Fact fact, FactSeq& tagsTraversed, int debugIndent) { - cout << "FactPattern::process entered" << endl; // ### - - for (int i = 0; i < debugIndent; i++) - cout << " "; - cout << "process " << fact << endl; for (JoinSeq::iterator it = joins.begin(); it != joins.end(); ++it) { Join* join = (*it).first; JoinSide side = (*it).second; - for (int i = 0; i < debugIndent; i++) - cout << " "; - cout << "join " << fact << " " << side << endl; - // Bind sub-facts to variables. if (tagsTraversed.begin() != tagsTraversed.end()) { FactSeq::iterator it = tagsTraversed.end(); @@ -224,7 +214,6 @@ Atom factValue = fact.get(name); // Get the value of attribute 'name'. if (!factValue.isNull()) { - // TO DO: Think about using a hash/map lookup here. for (PatternSeq::iterator it = namePattern->attributes.begin(); it != namePattern->attributes.end(); ++it) { FactPattern* valuePattern = *it; @@ -239,28 +228,21 @@ if (variableBinding.isNull()) { // Assign it. ruleState[slotNo] = factValue; - for (int i = 0; i < debugIndent; i++) - cout << " "; - cout << "matched attribute " << name << "=" << factValue << " (bind to [" << slotNo << "])" << endl; valuePattern->process(domain, ruleState, fact, tagsTraversed, debugIndent+1); // Go back to our previous state. ruleState[slotNo] = Atom(); } else - // If the variable is already bound, but it's equal to the fact value, then propagate. + // If the variable is already bound, but it's equal to the fact value, then propagate + // without making any state changes. if (variableBinding == factValue) { - for (int i = 0; i < debugIndent; i++) - cout << " "; - cout << "matched attribute " << name << "=" << factValue << " (bound already)" << endl; + valuePattern->process(domain, ruleState, fact, tagsTraversed, debugIndent+1); } } // If this pattern is an exact match, then propagate down that // branch. This doesn't change the ruleState, though. else if (valuePattern->value == factValue) { - for (int i = 0; i < debugIndent; i++) - cout << " "; - cout << "matched attribute " << name << "=" << factValue << endl; valuePattern->process(domain, ruleState, fact, tagsTraversed, debugIndent+1); } } @@ -277,7 +259,6 @@ // to match the next fact. Fact searchFact = fact; int levelChange = factPattern->levelChange; - cout << "LEVEL CHANGE = " << levelChange << endl; // ### while (levelChange < 1) { searchFact = searchFact.getParent(); assert(!searchFact.isNull()); @@ -293,8 +274,6 @@ FactSeq::iterator penultimate = tagsTraversed.end(); --penultimate; tagsTraversed.erase(penultimate, tagsTraversed.end()); - - cout << "FactPattern::process exited" << endl; // ### } @@ -315,7 +294,6 @@ void Join::process(Domain& domain, RuleState& newState, JoinSide side) { - cout << "Join::process entered" << endl; // ### int domainIndex = domain.getDomainIndex(); // Make sure joinStates is big enough. @@ -354,7 +332,6 @@ fire(domain, combinedState); } } - cout << "Join::process exited" << endl; // ### } void Join::fire(Domain& domain, RuleState& state) Index: proto1/RuleBase.cpp diff -u proto1/RuleBase.cpp:1.6 proto1/RuleBase.cpp:1.7 --- proto1/RuleBase.cpp:1.6 Wed Oct 3 03:41:54 2001 +++ proto1/RuleBase.cpp Wed Oct 3 03:55:11 2001 @@ -1,4 +1,4 @@ -// $Id: RuleBase.cpp,v 1.6 2001/10/03 10:41:54 blackh Exp $ +// $Id: RuleBase.cpp,v 1.7 2001/10/03 10:55:11 blackh Exp $ #include "Rule.h" #include "Engine.h" @@ -95,7 +95,6 @@ TagBindingSeq tagBindings; constructFact(thisPattern, lastLevel, 1, match->getFact(), tagBindings, 0); thisPattern->tagBindings = tagBindings; - cout << "GOT " << thisPattern->tagBindings.size() << " tag bindings" << endl; // ### } if (lastPattern != NULL) { Index: proto1/animal.xml +++ proto1/animal.xml <?xml version="1.0"?> <!-- $Id: animal.xml,v 1.1 2001/10/03 10:55:11 blackh Exp $ --> <grapevine> <demo.animal> <rules> a1 == <animal type="cat" colour="[C]" size="small" hair="[H]"/>, a2 == <animal type="dog" colour="[C]" size="[S]" hair="medium"/>, a3 == <animal type="cat" colour="[C]" size="large" hair="[H]"/>, a4 == <animal type="dog" colour="[C]" size="[S]" hair="long"/>; </rules> <facts> <animal type="cat" colour="yellow" size="large" hair="short"/> <animal type="cat" colour="calico" size="large" hair="short"/> <animal type="cat" colour="calico" size="small" hair="short"/> <animal type="dog" colour="brown" size="medium" hair="long"/> <animal type="cat" colour="brown" size="small" hair="medium"/> <animal type="dog" colour="brown" size="small" hair="short"/> <animal type="dog" colour="calico" size="medium" hair="medium"/> <animal type="dog" colour="brown" size="large" hair="medium"/> <animal type="dog" colour="calico" size="medium" hair="long"/> </facts> </demo.animal> </grapevine> |
From: blackh <gra...@li...> - 2001-10-03 10:41:55
|
blackh Wed Oct 3 03:41:54 2001 EDT Modified files: /proto1 Engine.cpp Engine.h Fact.cpp Fact.h RuleBase.cpp RuleBase.h Log: Binding of matched facts to variables now works. |
From: blackh <gra...@li...> - 2001-10-03 09:10:57
|
blackh Wed Oct 3 02:10:56 2001 EDT Modified files: /proto1 Engine.cpp Fact.cpp Fact.h Operation.cpp Operation.h Reference.h RuleBase.cpp RuleSAXHandler.cpp RuleSAXHandler.h grapevine.cpp Log: |
From: blackh <gra...@li...> - 2001-10-03 07:53:08
|
blackh Wed Oct 3 00:53:08 2001 EDT Modified files: /proto1 Fact.cpp Fact.h RuleBase.cpp Log: Facts and attributes can now be optional for the purposes of pattern matching. Index: proto1/Fact.cpp diff -u proto1/Fact.cpp:1.4 proto1/Fact.cpp:1.5 --- proto1/Fact.cpp:1.4 Mon Oct 1 00:24:50 2001 +++ proto1/Fact.cpp Wed Oct 3 00:53:07 2001 @@ -1,10 +1,43 @@ -// $Id: Fact.cpp,v 1.4 2001/10/01 07:24:50 blackh Exp $ +// $Id: Fact.cpp,v 1.5 2001/10/03 07:53:07 blackh Exp $ #include <iostream.h> #include "Fact.h" +// ------ Attribute --------------------------------------------------- +Attribute::Attribute() + : isOptional_(false) +{ +} + +Attribute::Attribute(String name, Atom value, bool isOptional) + : name(name), + value(value), + isOptional_(isOptional) +{ +} + +Attribute::Attribute(const Attribute& other) + : name(other.name), + value(other.value), + isOptional_(other.isOptional_) +{ +} + +Attribute::~Attribute() +{ +} + +Attribute& Attribute::operator = (const Attribute& other) +{ + name = other.name; + value = other.value; + isOptional_ = other.isOptional_; + return *this; +} + + // ------ FactImpl ---------------------------------------------------- FactImpl::FactImpl() @@ -23,11 +56,12 @@ { } -Fact::Fact(String name) +Fact::Fact(String name, bool isOptional) { FactImpl* x; init(OBJECT_TYPE_FACT, x = new FactImpl()); getImpl()->name = name; + getImpl()->isOptional = isOptional; } Fact Fact::getParent() @@ -44,13 +78,13 @@ if (it == attrs.end()) return Atom(); else - return (*it).second; + return (*it).second.getValue(); } -void Fact::set(String name, Atom value) +void Fact::set(String name, Atom value, bool isOptional) { assert(isFact() && !isNull()); - getImpl()->attrs[name] = value; + getImpl()->attrs[name] = Attribute(name, value, isOptional); } AttributeSeq& Fact::getAttributes() @@ -94,6 +128,12 @@ return (*it).second; } +bool Fact::isOptional() +{ + assert(isFact() && !isNull()); + return getImpl()->isOptional; +} + void Fact::add(Fact child) { assert(isFact() && !isNull()); @@ -121,8 +161,8 @@ os << "<" << getName(); for (AttributeSeq::iterator it = getAttributes().begin(); it != getAttributes().end(); ++it) { - Attribute attr = *it; - os << " " << attr.first << "=\"" << attr.second << "\""; + Attribute& attr = (*it).second; + os << " " << attr.getName() << "=\"" << attr.getValue() << "\""; } if (getText().isNull() && getChildren().begin() == getChildren().end()) Index: proto1/Fact.h diff -u proto1/Fact.h:1.4 proto1/Fact.h:1.5 --- proto1/Fact.h:1.4 Mon Oct 1 00:24:50 2001 +++ proto1/Fact.h Wed Oct 3 00:53:07 2001 @@ -1,4 +1,4 @@ -// $Id: Fact.h,v 1.4 2001/10/01 07:24:50 blackh Exp $ +// $Id: Fact.h,v 1.5 2001/10/03 07:53:07 blackh Exp $ #ifndef _FACT_H_ #define _FACT_H_ @@ -10,8 +10,27 @@ class Fact; -typedef pair<String, Atom> Attribute; -typedef map<String, Atom> AttributeSeq; +class Attribute +{ + private: + String name; + Atom value; + bool isOptional_; + + public: + Attribute(); + Attribute(String name, Atom value, bool isOptional = false); + Attribute(const Attribute& other); + ~Attribute(); + + Attribute& operator = (const Attribute& other); + + inline String getName() {return name;} + inline Atom getValue() {return value;} + inline bool isOptional() {return isOptional_;} +}; + +typedef map<String, Attribute> AttributeSeq; typedef map<String, Fact> OrderedFactSeq; typedef vector<Object> ObjectSeq; @@ -25,11 +44,11 @@ public: Fact(); - Fact(String name); + Fact(String name, bool isOptional = false); Fact getParent(); Atom get(String name); - void set(String name, Atom value); + void set(String name, Atom value, bool isOptional = false); AttributeSeq& getAttributes(); String& getName(); @@ -48,6 +67,8 @@ */ OrderedFactSeq& getOrderedChildren(); Fact getChild(String name); + + bool isOptional(); void add(Fact child); void add(String text); @@ -71,6 +92,13 @@ Atom text; ObjectSeq children; OrderedFactSeq orderedChildren; + + /** + * Used only in pattern matching, this field, if true, specifies that the + * fact in question is not required to be in the matching fact. The fact + * still needs to actually be in the pattern, though, because + */ + bool isOptional; FactImpl(); virtual ~FactImpl(); Index: proto1/RuleBase.cpp diff -u proto1/RuleBase.cpp:1.3 proto1/RuleBase.cpp:1.4 --- proto1/RuleBase.cpp:1.3 Tue Oct 2 22:30:42 2001 +++ proto1/RuleBase.cpp Wed Oct 3 00:53:07 2001 @@ -1,4 +1,4 @@ -// $Id: RuleBase.cpp,v 1.3 2001/10/03 05:30:42 rossta Exp $ +// $Id: RuleBase.cpp,v 1.4 2001/10/03 07:53:07 blackh Exp $ #include "Rule.h" #include "Engine.h" @@ -124,7 +124,7 @@ AttributeSeq& attributes = fact.getAttributes(); for (AttributeSeq::iterator it = attributes.begin(); it != attributes.end(); it++) { const String& name = (*it).first; - const Atom& value = (*it).second; + const Atom& value = (*it).second.getValue(); assert(pattern != NULL); pattern = pattern->createAttribute(name, value); } |
From: rossta <gra...@li...> - 2001-10-03 05:30:42
|
rossta Tue Oct 2 22:30:42 2001 EDT Modified files: /proto1 Domain.cpp Domain.h FactSAXHandler.cpp FactSAXHandler.h GrapevineSAXHandler.cpp GrapevineSAXHandler.h Optimizer.cpp Optimizer.h Reference.cpp Reference.h RuleBase.cpp RuleBase.h RuleSAXHandler.cpp RuleSAXHandler.h VarSlotAllocator.cpp VarSlotAllocator.h logic.xml test.xml utils.cpp Log: More $Id$s added |
From: blackh <gra...@li...> - 2001-10-03 01:05:15
|
blackh Tue Oct 2 18:05:15 2001 EDT Modified files: /proto1 Reference.cpp Rule.h configure.in Log: Added a warning to the compile options and fixed some bugs. Index: proto1/Reference.cpp diff -u proto1/Reference.cpp:1.2 proto1/Reference.cpp:1.3 --- proto1/Reference.cpp:1.2 Tue Oct 2 00:21:12 2001 +++ proto1/Reference.cpp Tue Oct 2 18:05:14 2001 @@ -27,6 +27,7 @@ variableSlot = other.variableSlot; factNames = other.factNames; attributeName = other.attributeName; + return *this; } void Reference::write(ostream& os) const Index: proto1/Rule.h diff -u proto1/Rule.h:1.4 proto1/Rule.h:1.5 --- proto1/Rule.h:1.4 Tue Oct 2 04:23:17 2001 +++ proto1/Rule.h Tue Oct 2 18:05:14 2001 @@ -1,4 +1,4 @@ -// $Id: Rule.h,v 1.4 2001/10/02 11:23:17 blackh Exp $ +// $Id: Rule.h,v 1.5 2001/10/03 01:05:14 blackh Exp $ #ifndef _RULE_H_ #define _RULE_H_ @@ -19,7 +19,7 @@ // Ensure that the compiler complains if we use these inadvertently. Rule(const Rule& other) {} - Rule& operator = (const Rule& other) {} + Rule& operator = (const Rule& other) {return *this;} public: Rule(); Index: proto1/configure.in diff -u proto1/configure.in:1.2 proto1/configure.in:1.3 --- proto1/configure.in:1.2 Sun Sep 30 12:16:07 2001 +++ proto1/configure.in Tue Oct 2 18:05:14 2001 @@ -1,7 +1,10 @@ -dnl $Id: configure.in,v 1.2 2001/09/30 19:16:07 rossta Exp $ +dnl $Id: configure.in,v 1.3 2001/10/03 01:05:14 blackh Exp $ AC_INIT(grapevine.cpp) AM_INIT_AUTOMAKE(grapevine, 0.1) + +CXXFLAGS="-Wreturn-type ${CXXFLAGS}" +CCFLAGS="-Wreturn-type ${CCFLAGS}" dnl checks for programs AC_PROG_CC |
From: blackh <gra...@li...> - 2001-10-02 12:11:14
|
blackh Tue Oct 2 05:11:13 2001 EDT Modified files: /proto1 Optimizer.cpp test.xml Log: Index: proto1/Optimizer.cpp diff -u proto1/Optimizer.cpp:1.3 proto1/Optimizer.cpp:1.4 --- proto1/Optimizer.cpp:1.3 Tue Oct 2 05:01:31 2001 +++ proto1/Optimizer.cpp Tue Oct 2 05:11:13 2001 @@ -34,8 +34,6 @@ ++nexter; Operation* op = *it; - cout << "op=" << *op << endl; - bool matched = false; Index: proto1/test.xml diff -u proto1/test.xml:1.7 proto1/test.xml:1.8 --- proto1/test.xml:1.7 Tue Oct 2 05:01:31 2001 +++ proto1/test.xml Tue Oct 2 05:11:13 2001 @@ -2,7 +2,19 @@ <grapevine> + <!-- This is how we define a namespace, called a 'domain' in grapevine --> <sys.demo> + + <!-- This allows rules defined inside <sys.main> to + read (i.e. do pattern matches) and write (i.e. assert + facts) in this domain. + + This gives 'object orientation' (sort of). + --> + <access> + <sys.main read="true" write="true"/> + </access> + <rules> animal1 == <animal colour="calico"/> == animal0, animal2 == <animal size="large"/>, |
From: blackh <gra...@li...> - 2001-10-02 12:01:32
|
blackh Tue Oct 2 05:01:31 2001 EDT Added files: /proto1 VarSlotAllocator.cpp VarSlotAllocator.h Modified files: /proto1 Makefile.am Operation.cpp Operation.h Optimizer.cpp Optimizer.h RuleSAXHandler.cpp RuleSAXHandler.h grapevine.cpp test.xml Log: |
From: blackh <gra...@li...> - 2001-10-02 11:23:17
|
blackh Tue Oct 2 04:23:17 2001 EDT Modified files: /proto1 Operation.cpp Operation.h Optimizer.cpp Reference.h Rule.cpp Rule.h Log: Index: proto1/Operation.cpp diff -u proto1/Operation.cpp:1.6 proto1/Operation.cpp:1.7 --- proto1/Operation.cpp:1.6 Tue Oct 2 03:41:05 2001 +++ proto1/Operation.cpp Tue Oct 2 04:23:17 2001 @@ -1,4 +1,4 @@ -// $Id: Operation.cpp,v 1.6 2001/10/02 10:41:05 blackh Exp $ +// $Id: Operation.cpp,v 1.7 2001/10/02 11:23:17 blackh Exp $ #include "Operation.h" #include "Fact.h" @@ -18,9 +18,20 @@ { } +void Match::addBinding(Reference ref) +{ + bindings.insert(bindings.end(), ref); +} + void Match::write(ostream& os) { - os << "match " << fact; + os << "match " << fact << " {"; + for (ReferenceSeq::iterator it = bindings.begin(); it != bindings.end(); ++it) { + if (it != bindings.begin()) + os << ", "; + os << *it; + } + os << "}"; } Index: proto1/Operation.h diff -u proto1/Operation.h:1.5 proto1/Operation.h:1.6 --- proto1/Operation.h:1.5 Tue Oct 2 02:33:19 2001 +++ proto1/Operation.h Tue Oct 2 04:23:17 2001 @@ -1,4 +1,4 @@ -// $Id: Operation.h,v 1.5 2001/10/02 09:33:19 blackh Exp $ +// $Id: Operation.h,v 1.6 2001/10/02 11:23:17 blackh Exp $ #ifndef _OPERATION_H_ #define _OPERATION_H_ @@ -26,13 +26,14 @@ return os; } -typedef vector<Reference> seq; +typedef vector<Reference> ReferenceSeq; class Match : public Operation { private: Domain& domain; Fact fact; + ReferenceSeq bindings; public: Match(Domain& domain, Fact fact); @@ -41,6 +42,8 @@ inline Domain& getDomain() {return domain;} inline Fact& getFact() {return fact;} + void addBinding(Reference ref); + virtual void write(ostream& os); }; @@ -60,7 +63,7 @@ public: ReferenceOperation(Reference ref); - inline Reference& getRef() {return ref;} + inline Reference& getReference() {return ref;} virtual void write(ostream& os); }; Index: proto1/Optimizer.cpp diff -u proto1/Optimizer.cpp:1.1 proto1/Optimizer.cpp:1.2 --- proto1/Optimizer.cpp:1.1 Tue Oct 2 02:33:19 2001 +++ proto1/Optimizer.cpp Tue Oct 2 04:23:17 2001 @@ -1,5 +1,7 @@ #include "Optimizer.h" #include "RuleListener.h" +#include "Operation.h" +#include "Rule.h" Optimizer::Optimizer(RuleListener& listener) : listener(listener) @@ -10,9 +12,67 @@ { } +typedef list<Operation*> OperationList; + String Optimizer::process(Rule* rule) { - listener.process(rule); + OperationList ops; + + // Move all the operations into our linked list. + for (OperationSeq::iterator it = rule->operations.begin(); it != rule->operations.end(); ++it) + ops.insert(ops.end(), *it); + rule->operations.clear(); // Make sure Rule's destructor doesn't delete our ops + delete rule; + + OperationList::iterator it = ops.begin(); + while (it != ops.end()) { + OperationList::iterator next = it; + ++next; + Operation* op = *it; + + bool matched = false; + // Binding the expression to a simple variable. + + Match* match = dynamic_cast<Match*>(op); + if (match != NULL) { + if (next != ops.end()) { + ReferenceOperation* ref = dynamic_cast<ReferenceOperation*>(*next); + if (ref != NULL && ref->getReference().isVariableOnly()) { + OperationList::iterator nexter = next; + ++nexter; + if (nexter != ops.end()) { + Bind* bind = dynamic_cast<Bind*>(*nexter); + if (bind != NULL) { + ++nexter; + ops.erase(next, nexter); + match->addBinding(ref->getReference()); + delete ref; + delete bind; + matched = true; + } + } + } + } + } + if (!matched) + it = next; + } + + cout << endl; + cout << "OPTIMIZED CODE" << endl; + + for (it = ops.begin(); it != ops.end(); ++it) { + Operation* op = *it; + cout << " ## " << *op << endl; + } + cout << endl; + + Rule* newRule = new Rule(); + + for (it = ops.begin(); it != ops.end(); ++it) + newRule->add(*it); + + listener.process(newRule); return String(); -} +} Index: proto1/Reference.h diff -u proto1/Reference.h:1.2 proto1/Reference.h:1.3 --- proto1/Reference.h:1.2 Tue Oct 2 00:21:12 2001 +++ proto1/Reference.h Tue Oct 2 04:23:17 2001 @@ -38,7 +38,11 @@ int getVariableSlot() {return variableSlot;} StringSeq& getFactNames() {return factNames;} String getAttributeName() {return attributeName;} - + + bool isVariableOnly() { + return factNames.size() == 0 && attributeName.isNull(); + } + void write(ostream& os) const; }; Index: proto1/Rule.cpp diff -u proto1/Rule.cpp:1.2 proto1/Rule.cpp:1.3 --- proto1/Rule.cpp:1.2 Sun Sep 30 12:16:07 2001 +++ proto1/Rule.cpp Tue Oct 2 04:23:17 2001 @@ -1,4 +1,4 @@ -// $Id: Rule.cpp,v 1.2 2001/09/30 19:16:07 rossta Exp $ +// $Id: Rule.cpp,v 1.3 2001/10/02 11:23:17 blackh Exp $ #include <iostream.h> @@ -12,8 +12,10 @@ Rule::~Rule() { // Delete all the operations contained in this rule. - for (OperationSeq::iterator it = operations.begin(); it != operations.end(); ++it) + for (OperationSeq::iterator it = operations.begin(); it != operations.end(); ++it) { Operation* op = *it; + delete op; + } } void Rule::add(Operation* operation) Index: proto1/Rule.h diff -u proto1/Rule.h:1.3 proto1/Rule.h:1.4 --- proto1/Rule.h:1.3 Sun Sep 30 12:16:07 2001 +++ proto1/Rule.h Tue Oct 2 04:23:17 2001 @@ -1,4 +1,4 @@ -// $Id: Rule.h,v 1.3 2001/09/30 19:16:07 rossta Exp $ +// $Id: Rule.h,v 1.4 2001/10/02 11:23:17 blackh Exp $ #ifndef _RULE_H_ #define _RULE_H_ @@ -9,14 +9,13 @@ typedef vector<Operation*> OperationSeq; -class RuleBase; - class Rule { friend class RuleBase; + friend class Optimizer; private: OperationSeq operations; - int noOfSlots; + int noOfSlots; // ?? Is this still used? // Ensure that the compiler complains if we use these inadvertently. Rule(const Rule& other) {} |
blackh Tue Oct 2 03:41:05 2001 EDT Modified files: /proto1 Domain.cpp Domain.h Engine.cpp Engine.h FactSAXHandler.cpp FactSAXHandler.h GrapevineSAXHandler.cpp Operation.cpp RuleBase.cpp RuleBase.h RuleSAXHandler.cpp RuleSAXHandler.h Log: |
From: blackh <gra...@li...> - 2001-10-02 09:33:20
|
blackh Tue Oct 2 02:33:19 2001 EDT Added files: /proto1 Domain.cpp Domain.h Optimizer.cpp Optimizer.h RuleBase.cpp RuleBase.h Modified files: /proto1 Engine.cpp Engine.h FactListener.h FactSAXHandler.cpp FactSAXHandler.h GrapevineSAXHandler.cpp GrapevineSAXHandler.h Makefile.am Object.cpp Object.h Operation.cpp Operation.h RuleSAXHandler.cpp RuleSAXHandler.h grapevine.cpp test.xml Log: |
From: blackh <gra...@li...> - 2001-10-02 07:21:13
|
blackh Tue Oct 2 00:21:12 2001 EDT Modified files: /proto1 Object.cpp Object.h Operation.cpp Operation.h Reference.cpp Reference.h RuleSAXHandler.cpp RuleSAXHandler.h test.xml utils.h Log: |
blackh Mon Oct 1 06:10:58 2001 EDT Added files: /proto1 Reference.cpp Reference.h logic.xml Modified files: /proto1 Engine.cpp Makefile.am Object.cpp Object.h Operation.cpp Operation.h RuleSAXHandler.cpp RuleSAXHandler.h grapevine.cpp test.xml Log: It now does most of the parsing. |
From: blackh <gra...@li...> - 2001-10-01 11:45:31
|
blackh Mon Oct 1 04:45:30 2001 EDT Modified files: /proto1 Engine.cpp GrapevineSAXHandler.cpp GrapevineSAXHandler.h Object.cpp Object.h RuleSAXHandler.cpp RuleSAXHandler.h Log: |
From: blackh <gra...@li...> - 2001-10-01 11:21:02
|
blackh Mon Oct 1 04:21:01 2001 EDT Modified files: /proto1 FactSAXHandler.cpp Object.cpp Object.h README RuleSAXHandler.cpp RuleSAXHandler.h test.xml utils.cpp utils.h Log: |
From: blackh <gra...@li...> - 2001-10-01 09:48:48
|
blackh Mon Oct 1 02:48:48 2001 EDT Modified files: /proto1 grapevine.cpp Log: Puts facts into engine. Index: proto1/grapevine.cpp diff -u proto1/grapevine.cpp:1.8 proto1/grapevine.cpp:1.9 --- proto1/grapevine.cpp:1.8 Mon Oct 1 02:39:46 2001 +++ proto1/grapevine.cpp Mon Oct 1 02:48:48 2001 @@ -1,4 +1,4 @@ -// $Id: grapevine.cpp,v 1.8 2001/10/01 09:39:46 blackh Exp $ +// $Id: grapevine.cpp,v 1.9 2001/10/01 09:48:48 blackh Exp $ #include <iostream.h> #include <util/PlatformUtils.hpp> @@ -166,8 +166,13 @@ SAX2XMLReader* parser = XMLReaderFactory::createXMLReader(); try { - FactSAXHandler factHandler(factDumper); - RuleSAXHandler ruleHandler(ruleDumper); + RuleBase ruleBase; + Engine engine(ruleBase); + + // Blast facts and rules into the engine. + RuleSAXHandler ruleHandler(engine); + FactSAXHandler factHandler(engine); + GrapevineSAXHandler handler(ruleHandler, factHandler); parser->setContentHandler(&handler); parser->setErrorHandler(&handler); |
blackh Mon Oct 1 02:39:46 2001 EDT Added files: /proto1 GrapevineSAXHandler.cpp GrapevineSAXHandler.h RuleSAXHandler.cpp RuleSAXHandler.h Modified files: /proto1 FactSAXHandler.cpp FactSAXHandler.h Makefile.am Object.cpp Object.h grapevine.cpp test.xml utils.cpp utils.h Log: It now reads facts from an XML file. |
From: blackh <gra...@li...> - 2001-10-01 07:24:51
|
blackh Mon Oct 1 00:24:50 2001 EDT Added files: /proto1 FactSAXHandler.cpp FactSAXHandler.h test.xml utils.cpp Modified files: /proto1 Fact.cpp Fact.h FactListener.h Makefile.am Object.cpp Object.h grapevine.cpp utils.h Log: |
From: blackh <gra...@li...> - 2001-09-30 23:03:17
|
blackh Sun Sep 30 16:03:16 2001 EDT Added files: /paper1/doc language-example1.xml language-example2.xml Modified files: /paper1/doc design.argo Log: Index: paper1/doc/design.argo diff -u paper1/doc/design.argo:1.3 paper1/doc/design.argo:1.4 --- paper1/doc/design.argo:1.3 Sun Sep 30 05:29:28 2001 +++ paper1/doc/design.argo Sun Sep 30 16:03:16 2001 @@ -47,7 +47,7 @@ <stat name="longestHot" value="0" /> <stat name="numCriticsFired" - value="406871" /> + value="1913796" /> <stat name="numNotValid" value="85" /> <stat name="numCriticsApplied" Index: paper1/doc/language-example1.xml +++ paper1/doc/language-example1.xml <?xml version="1.0"?> <messages> <!-- SOME FACTS --> <!-- Messages can be prioritized numerically and/or by specifying a future time --> <message priority="5"></message> <message time="15:02:42"></message> <message priority="0"> <dest> <node loc="12312321321312332"/> </dest> <fact> <wants req="12312311123123"> <key chk="423242423432424324"/> </wants> </fact> </message> <!-- This message then appears at the other end like this: --> <says> <authority> <node loc="464565464564645"/> </authority> <fact> <wants req="12312311123123"> <key chk="423242423432424324"/> </wants> </fact> </says> <neighbour loc="12312321321312332"> </neighbour> <!-- LOGIC --> <!-- Routing algorithm --> <rule> <if label="X"> <says> <fact> <wants req="R"> <key/> </wants> </fact> </says> </if> <if> <neighbour loc="L"/> </if> <gimme label="Y"> <route req="R"> <neighbour loc="L"/> </route> </gimme> <calc label="P">X.says.fact.wants.key#loc-L</calc> <add label="Y"> <route><neighbour proximity="P"/></route> </add> </rule> <!-- --> <rule> <if assign="Says"> <says> <fact> <wants req="R"> <key value="K" type="T"/> </wants> </fact> </says> </if> <ifnot> <route req="R"/> </ifnot> <assert> <route req="R" state="deciding" priority="0"> <key value="K" type="T"/> <fact>Says.fact.*</fact> <dest> <node loc="Neighbours.neighbour#loc"/> </dest> </route> </assert> </rule> <!-- Found file in our memory --> <rule> <if assign="Route"> <route state="deciding"/> </if> <if assign="File"> <file key="Route.key#loc"/> </if> <retract fact="Route"/> <assert> <message priority="0"> <dest>Route.src</dest> <fact> <File/> </fact> </message> </assert> </rule> Route=<route state="deciding/">, File=<file key="Route.key#loc"/>, retract Route, assert <message priority="0"> <dest>Route.src</dest> <fact>File</fact> </message>; Message= <says> <authority> <node/> </authority> <that> <file name="Name" owner="Owner1"/> </that> </says>, File=<file name="Name" owner="Owner2"/>, Owner1 != Owner2, retract Message, assert <liar>Message.says.authority.node</liar>; Liar=<liar><node loc="Loc"/></liar>, ... hmmm ... <rule> <if assign="Route"> <route req="R" state="routing"/> </if> <all assign="Neighbours"> <neighbour/> </all> <least assign="Neighbours" no="32" list="Neighbours">distance(K-N#loc)</least> <least assign="Neighbours" no="16" list="Neighbours" iter="N">N.avgPingTime</least> <most assign="Neighbours" no="1" list="Neighbours" iter="N">N.karmicDebt</most> <add to="Route"> <route state="queueing"><dest>Neighbours.neighbour</dest></route> </add> </rule> <rule> <all assign="Routes"> <route state="queueing"/> </all> <least assign="Routes" no="1" list="Routes">route.priority</least> <add to="Routes.route"> <route state="sent"></route> </add> <send to="Routes.dest.neighbour#addr"> </send> </rule> </messages> Index: paper1/doc/language-example2.xml +++ paper1/doc/language-example2.xml <?xml version="1.0"?> <grapevine> <module name="grapevine"> <logic name="processing-received-messages"> retract recv=<recv/>, { req=recv/request, <!-- Fails if the value is null --> { <processing re="[re]"/> || req#state="processing", req/from=recv/from, assert req } || (data=recv/data) != null, <processing re="[re]"/>, assert <send> <to>[processing/req/from/]</to> [recv/data] </send> }; </logic> <logic name="address-handling"> <!-- Return the contents of a file --> req=<request state="processing" re="[re]">[key1=]<key/></request>, retract req, to=req/to, { <file>[key2=]<key/></file>, key1 == key2, assert <send priority="0" re="[req#re]"> <!-- or just [re] --> [to] [file/data] </send> || assert <processing state="route" re="[re]">[req]</processing>, }; </logic> <!-- Logic for routing to nearest matching key --> <logic name="routing"> proc=<processing state="route"/>, req=proc/request, requestKeyHash=req/key#hash, matches=least(1,<neighbour><key hash="[neighbourHash]"/></neighbour>, distance(neighbourHash - requestKeyHash)), <!-- tricky --> { length(matches) > 0, neighbour=matches/neighbour, proc#state="wait", delete(req/from), assert <send priority="0" re="[req#re]"> <to>[req/from/]</to> <!-- Note this variation on syntax --> <processing/> </send>, assert <send priority="0" re="[req#re]"> <to>[neighbour/node]</to> [req] </send> || retract proc, assert <send priority="0" re="[req#re]"> <to>[req/from/]</to> <data none="true"/> </send> }; <logic name="reply-handling"> </logic> </logic> </module> </grapevine> |