def main(): fac5 = dedent('''\ ;; factorial : number -> number ;; to calculate the product of all positive ;; integers less than or equal to n. (letrec ((fact (lambda (x) (if (= x 0) 1 (* x (fact (- x 1))))))) (fact 5)) ''') evenodd = dedent('''\ (letrec ((even? (lambda (n) (if (zero? n) #t (odd? (- n 1))))) (odd? (lambda (n) (if (zero? n) #f (even? (- n 1)))))) (even? 88))''') e = fac5 print('; original') print(e) print('; parsed') e_parsed = parse(e) print(pretty(e_parsed)) print('; ast') e_ast = ast(e) print(e_ast) print('; cps ast') e_cps = T_c(e_ast, halt) print(e_cps) gen = CodeGenerator() print(gen.code_gen(T_c(e_ast, gen.retExp))) return 0
def __repr__(self): pretty(self.toSExp())
def __repr__(self): return pretty(self.toSExp())