-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathchezjs
executable file
·33 lines (25 loc) · 952 Bytes
/
chezjs
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
#!/bin/bash
":"; export CHEZSCHEMELIBDIRS=.:lib:/usr/local/lib && export CHEZSCHEMELIBEXTS=.chezscheme.sls::.chezscheme.so:.ss::.so:.sls::.so:.scm::.so:.sch::.so:.sc::.so && exec scheme --script $0 "$@";
(import (compiler))
(import (only (core io) read-file write-file))
(define inputloop
(lambda ()
(display "> ")
(display
(eval
(car
(js->scheme
(let loop ((c (read-char)))
(case c
(#\newline '())
(else (cons c (loop (read-char))))))))))
(newline)
(inputloop)))
(if (= (length (command-line-arguments)) 1)
(let* ((source-name (car (command-line-arguments)))
(output-name (string-append source-name ".sc")))
(when (file-exists? output-name) (delete-file output-name))
(write-file output-name (js->scheme
(read-file source-name)))
(compile-file output-name))
(inputloop))