There's still a lot of code to be written for the RuleCompiler but I came a bit further today. I've added print statements to the parser so I can trace the creation of the Rete Network.
>>> def rule1(self, large = Large, medium = Medium, small = Small):I'm about 90% done. It took about 8h of programming, spread out during a week. I figure the last 10% will take at least as long. They always seem to do. But this is good. In my previous attempts it took me a lot longer to get this far.
... salience = 10
... if large(value == x and x > 10, another == y) and \
... medium(value == y and y > x, another == z) and \
... small(value == z):
# p = ProductionNode(rule = rule1)
# p.doc = None
# o1 = ObjectTypeNode(type = Small)
# o2 = ObjectTypeNode(type = Medium)
# o3 = ObjectTypeNode(type = Large)
# p.salience = 10
# x = large.value
# a1 = AlphaNode(large.value > 10)
# y = large.another
# j1 = JoinNode(large.another == medium.value)
# a2 = AlphaNode(large.another > large.value)
# z = medium.another
# j2 = JoinNode(medium.another == small.value)
A couple of days ago I thought I could lose the fact bindings (the method parameters) but it occured to me today that they are needed if one or more of the Facts are to be referenced in the RHS. So, the bindings stay.
And, regarding python4ply I've decided to do without it at the moment. The only thing I've found I really miss is the ability to use ? to distinguish a variable name from an attribute name. Without it there's no way a variable can have the same name as an attribute.