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:
26
libs/repl.gst
Normal file
26
libs/repl.gst
Normal 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))
|
||||
Reference in New Issue
Block a user