-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.scm
39 lines (31 loc) · 919 Bytes
/
main.scm
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
;; main.scm
(define (println data)
(newline)
(display data)
(newline)
'done)
(define (setup-env)
(let ((init-env (extend-env (primitive-procs-names)
(primitive-proc-vals)
empty-env)))
(define-variable! 'true true init-env)
(define-variable! 'false false init-env)
init-env))
(define global-env (setup-env))
(define apply-in-scheme apply)
(define input-prompt ">> ")
(define output-prompt "Value:")
(define (user-print obj)
(if (compound-procedure? obj)
(display (list 'compound-procedure
(proc-params obj)
(proc-body obj)
'<procedure-env>))
(display obj)))
(define (driver-loop)
(println input-prompt)
(let ((input (read)))
(let ((output (eval input global-env)))
(println output-prompt)
(user-print output)))
(driver-loop))