mirror of
https://github.com/janet-lang/janet
synced 2024-12-25 07:50:27 +00:00
27 lines
508 B
Plaintext
27 lines
508 B
Plaintext
(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))
|