-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbones-repl
More file actions
executable file
·34 lines (29 loc) · 842 Bytes
/
bones-repl
File metadata and controls
executable file
·34 lines (29 loc) · 842 Bytes
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
#!/bin/scheme /grass/16/boot
;;;; -*- Scheme -*-
(require 'sh)
(define options (command-line-arguments))
(with-temporary-files
(lambda ()
(let* ((tmp (temporary-file "repl" "scm"))
(stmp (replace-suffix "s" tmp))
(otmp (replace-suffix "o" tmp))
(xtmp (strip-suffix tmp)))
(let loop ()
(print* "bones> ")
(let ((x (read)))
(unless (eof-object? x)
(with-output-to-file tmp
(lambda ()
(pp `(program
(include "base.scm")
(code
(write ,x)
(newline))))))
(and (zero? (run* (./bones ,tmp -o ,stmp ,@options)))
(zero? (run* (nasm -f elf64 -g -F dwarf ,stmp -o ,otmp -DENABLE_GC_LOGGING)))
(zero? (if (member "nolibc" options)
(run* (ld ,otmp -o ,xtmp))
(run* (bin/musl-gcc ,otmp -o ,xtmp))))
(run* (,xtmp)))
(loop))))
(newline))))