1
0
mirror of https://github.com/janet-lang/janet synced 2025-11-01 16:13:02 +00:00

Making some changes.

This commit is contained in:
bakpakin
2017-07-15 12:21:06 -04:00
parent 8c20b7229a
commit 57886db410
6 changed files with 66 additions and 7 deletions

26
libs/repl.gst Normal file
View File

@@ -0,0 +1,26 @@
(var *sourcefile* stdin)
(var *compile* (fn [x]
(def ret (compile x))
(if (= :function (type ret))
ret
(error (string "compile error: " ret)))))
(var *read* (fn []
(def b (buffer))
(def p (parser))
(while (not (parse-hasvalue p))
(read *sourcefile* 1 b)
(if (= (length b) 0)
(error "unexpected end of source"))
(parse-charseq p b)
(clear b))
(parse-consume p)))
(def eval (fn [x]
(apply (*compile* x) 123)))
(def t (thread (fn []
(while true
(eval (*read*))))))
(print (tran t))