-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
181d8d3
commit bcfd3b0
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
;; Consider this variant of cps-of-exps | ||
(load-relative "../libs/init.scm") | ||
(load-relative "./base/test.scm") | ||
(load-relative "./base/cps.scm") | ||
(load-relative "./base/data-structures.scm") | ||
(load-relative "./base/cps-cases.scm") | ||
(load-relative "./base/cps-lang.scm") | ||
(load-relative "./base/base-iterp.scm") | ||
|
||
;; This version of cps-of-exps is continuation passing style, | ||
;; like the optimized version fact, acc used as cont. | ||
|
||
(define cps-of-exps | ||
(lambda (exps builder) | ||
(let cps-of-rest ((exps exps) (acc '())) | ||
;; cps-of-rest : Listof(InpExp) × Listof(SimpleExp) → TfExp | ||
(cond | ||
((null? exps) (builder (reverse acc))) | ||
((inp-exp-simple? (car exps)) | ||
(cps-of-rest (cdr exps) | ||
(cons | ||
(cps-of-simple-exp (car exps)) | ||
acc))) | ||
(else | ||
(let ((var (fresh-identifier 'var))) | ||
(cps-of-exp (car exps) | ||
(cps-proc-exp | ||
(list var) | ||
(cps-of-rest | ||
(cdr exps) | ||
(cons (cps-of-simple-exp (var-exp var)) acc)))))))))) | ||
|
||
(run-all) |