Beispiel #1
0
 def evaluate_i(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)
Beispiel #2
0
 def evaluate_i(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)))
Beispiel #3
0
def first(dynamic):
    return utils.create_boolean(dynamic.context_position == 1)
Beispiel #4
0
def last(dynamic):
    return utils.create_boolean(dynamic.context_position == dynamic.context_size)
Beispiel #5
0
def position(dynamic, check=None):
    if check is None:
        return utils.create_number(dynamic.context_position)
    return utils.create_boolean(
            utils.get_single_instance(check, d.Number).get_as_int() == dynamic.context_position)