/
yaspl.rkt
47 lines (35 loc) · 1.52 KB
/
yaspl.rkt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#lang racket
(require
"parser.rkt"
"resolve-module.rkt"
"lift-module.rkt"
(prefix-in le: "lifted-evaluator.rkt"))
(define (read-yaspl-file path)
(call-with-input-file path
(lambda (port)
(port-count-lines! port)
(parse-yaspl (read-syntax path port)))))
(define unit-module (read-yaspl-file "yaspl/unit.ysp"))
(define bool-module (read-yaspl-file "yaspl/bool.ysp"))
(define bool2-module (read-yaspl-file "yaspl/bool2.ysp"))
(define maybe-module (read-yaspl-file "yaspl/maybe.ysp"))
(define nat-module (read-yaspl-file "yaspl/natural.ysp"))
(define pair-module (read-yaspl-file "yaspl/pair.ysp"))
(define list-module (read-yaspl-file "yaspl/list.ysp"))
(define lists-module (read-yaspl-file "yaspl/lists.ysp"))
(define bool-program1 (read-yaspl-file "yaspl/bool-prog1.ysp"))
(define bool-program2 (read-yaspl-file "yaspl/bool-prog2.ysp"))
(define color-module (read-yaspl-file "yaspl/color.ysp"))
(define queue-module (read-yaspl-file "yaspl/queue.ysp"))
(define modules (list bool-module pair-module unit-module bool2-module maybe-module nat-module list-module lists-module queue-module))
(define lifted-modules (map lift-module (resolve-modules modules)))
(define (run fun arg)
(le:run (le:initialize-program lifted-modules fun arg)))
(run '(bool main) '(bool True))
(run '(bool2 main) '(bool2 arg))
(run '(maybe isJust) '(maybe nothing))
(run '(maybe main) '(bool True))
(run '(nat main) '(nat zero))
(run '(list single) '(bool True))
(run '(lists app-to-bool-list) '(list reverse))
;(run '(queue main) '(bool True))