-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREP.rkt
31 lines (27 loc) · 836 Bytes
/
REP.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
#lang racket
(require "parse.rkt")
(require "env.rkt")
(require "interp.rkt")
(provide read-eval-print)
(define read-eval-print
(lambda ()
(let ([orig (error-escape-handler)])
(let/ec exit
(let retry-loop ()
(let/ec escape
(error-escape-handler
(lambda () (escape #f)))
(let loop ()
(begin
(display "MS> ")
(let ([in (read)])
(if (eq? in 'exit )
(begin
(printf "returning to Scheme proper~n")
(exit #f))
(begin
(display (eval-exp (parse in) init-env))
(newline)
(loop)))))))
(retry-loop)))
(error-escape-handler orig))))