-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrepl.scm
41 lines (35 loc) · 866 Bytes
/
repl.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
40
41
(import
(scheme base)
(scheme char)
(only (scheme cxr))
(scheme eval)
(only (scheme file))
(only (scheme inexact))
(only (scheme lazy))
(scheme process-context)
(scheme read)
(scheme repl)
(only (scheme time))
(scheme write))
(define (main)
(display "> " (current-error-port))
(let loop ()
(let ((char (peek-char)))
(cond
((char-whitespace? char)
(read-char)
(loop))
((or (eof-object? char) (eqv? char (integer->char 4)))
#f)
(else
(write (eval (read) (interaction-environment)))
(newline)
(main))))))
(let ((arguments (command-line)))
(when (or
(member "-h" arguments)
(member "--help" arguments))
(write-string "The Stak Scheme REPL interpreter.\n\n")
(write-string "Usage: stak-repl\n")
(exit)))
(main)