Пример #1
0
def evalIf(exp, env, cont):
    def c(predicate_val):
        if expressions.isTrue(predicate_val):
            return teval(expressions.ifConsequent(exp), env, cont)
        else:
            return teval(expressions.ifAlternative(exp), env, cont)
    return teval(expressions.ifPredicate(exp), env, c)
Пример #2
0
def evalIf(exp, env, cont):
    def c(predicate_val):
        if expressions.isTrue(predicate_val):
            return teval(expressions.ifConsequent(exp), env, cont)
        else:
            return teval(expressions.ifAlternative(exp), env, cont)

    return teval(expressions.ifPredicate(exp), env, c)
Пример #3
0
def analyzeIf(exp):
    analyzedPredicate = analyze(expressions.ifPredicate(exp))
    analyzedConsequent = analyze(expressions.ifConsequent(exp))
    analyzedAlternative = analyze(expressions.ifAlternative(exp))
    def analyzed(env, cont):
        def c(predicateVal):
            if expressions.isTrue(predicateVal):
                return pogo.bounce(analyzedConsequent, env, cont)
            else:
                return pogo.bounce(analyzedAlternative, env, cont)
        return pogo.bounce(analyzedPredicate, env, c)
    return analyzed
Пример #4
0
 def t_expand_if(self, expr, cont):
     pred = expressions.ifPredicate(expr)
     consq = expressions.ifConsequent(expr)
     altern = expressions.ifAlternative(expr)
     def c_pred(pred_value):
         def c_conseq(consequent_value):
             def c_altern(alternative_value):
                 return pogo.bounce(cont,
                                    expressions.makeIf(pred_value,
                                                       consequent_value,
                                                       alternative_value))
             return pogo.bounce(self.t_expand, altern, c_altern)
         return pogo.bounce(self.t_expand, consq, c_conseq)
     return pogo.bounce(self.t_expand, pred, c_pred)