def OR_handler(exp): """We have to consider three cases: (OR) ===> #t (OR e1) ===> e1 (OR e1 e2 ...) ===> (let ((temp-val e1)) (IF temp-val temp-val (OR e2 ...))) ===> ((lambda (temp-val) (IF temp-val temp-val (OR e2 ...))) e1) """ clauses = and_clauses(exp) if pair.length(clauses) == 0: return symbol.true elif pair.length(clauses) == 1: return pair.car(clauses) else: temporarySymbol = symbol.makeUniqueTemporary() lambdaVal = expressions.makeLambda( pair.list(temporarySymbol), pair.list(expressions.makeIf(temporarySymbol, temporarySymbol, makeOr(pair.cdr(clauses))))) return expressions.makeApplication( lambdaVal, pair.list(pair.car(clauses)))
def c_expanded(expandedBody): return pogo.bounce(cont, expressions.makeLambda(parameters, expandedBody))