-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun.scm
34 lines (30 loc) · 872 Bytes
/
run.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
; We import all libraries here because the compiler strips any unimported libraries.
(import
(scheme base)
(scheme char)
(only (scheme cxr))
(only (scheme eval) eval)
(scheme file)
(only (scheme inexact))
(only (scheme lazy))
(scheme process-context)
(scheme read)
(scheme repl)
(only (scheme time))
(only (scheme write)))
(define (main)
(define program (open-input-file (list-ref (command-line) 1)))
(do ()
((eof-object? (peek-char program))
#f)
(if (char-whitespace? (peek-char program))
(read-char program)
(eval (read program) (interaction-environment)))))
(let ((arguments (command-line)))
(when (or
(member "-h" arguments)
(member "--help" arguments))
(write-string "The Stak Scheme interpreter.\n\n")
(write-string "Usage: stak SOURCE_FILE [ARGUMENTS]...\n")
(exit)))
(main)