Example #1
0
 def generate(self, static, dynamic, local, var_stream):
     expr = self.expr
     for var_set in var_stream:
         new_local = local.new(set_map=var_set)
         result = expr.evaluate(static, dynamic, new_local)
         if utils.boolean(result):
             yield var_set
Example #2
0
 def evaluate(self, static, dynamic, local):
     name = self.name
     expr_value = self.expr.evaluate(static, dynamic, local)
     condition = self.condition
     if self.type == "some": # Existential quantification
         for value in expr_value:
             new_local = local.new(set_name=name, set_value=d.StandardSequence([value]))
             if utils.boolean(condition.evaluate(static, dynamic, new_local)):
                 return utils.create_boolean(True)
         return utils.create_boolean(False)
     elif self.type == "every": # Universal quantification
         for value in expr_value:
             new_local = local.new(set_name=name, set_value=d.StandardSequence([value]))
             if not utils.boolean(condition.evaluate(static, dynamic, new_local)):
                 return utils.create_boolean(False)
         return utils.create_boolean(True)
     else:
         raise Exception("Invalid quantification type: " + self.type)
Example #3
0
 def evaluate(self, static, dynamic, local):
     # TODO: same thing about synthetic lists as with Path
     sequence = self.left.evaluate(static, dynamic, local)
     sequence_size = sequence.get_size()
     results = [None for s in xrange(sequence_size)]
     for i in xrange(sequence_size):
         item = sequence.get_item(i)
         new_dynamic = dynamic.new(context_size=sequence_size, context_item=item, context_position=i + 1)
         if utils.boolean(self.right.evaluate(static, new_dynamic, local)):
             results[i] = item
     return d.StandardSequence([x for x in results if x is not None])
Example #4
0
 def evaluate(self, static, dynamic, local):
     condition = utils.boolean(self.condition.evaluate(static, dynamic, local))
     if condition:
         return self.true.evaluate(static, dynamic, local)
     else:
         return self.false.evaluate(static, dynamic, local)
Example #5
0
 def evaluate(self, static, dynamic, local):
     left = self.left.evaluate(static, dynamic, local)
     if utils.boolean(left):
         return utils.create_boolean(True)
     return utils.create_boolean(utils.boolean(self.right.evaluate(static, dynamic, local)))