mirror of
https://github.com/janet-lang/janet
synced 2024-12-26 00:10:27 +00:00
4fd398ac97
support for error handling, macros and other compile time transformations. This will eventually become the full language.
28 lines
589 B
Plaintext
28 lines
589 B
Plaintext
(namespace-set! "gst.repl")
|
|
|
|
"Hold all compile time evaluators"
|
|
(export! "evaluators" {})
|
|
|
|
"Read a line"
|
|
(export! "readline" (fn []
|
|
(: b (buffer))
|
|
(read stdin 1 b)
|
|
(while (not (= (get "\n" 0) (get b (- (length b) 1))))
|
|
(read stdin 1 b)
|
|
)
|
|
(string b)
|
|
))
|
|
|
|
"Create a parser"
|
|
(export! "p" (parser))
|
|
|
|
"Run a simple repl. Does not handle errors and other
|
|
such details."
|
|
(while 1
|
|
(write stdout ">> ")
|
|
(: line (readline))
|
|
(while line
|
|
(: line (parse-charseq p line))
|
|
(if (parse-hasvalue p)
|
|
(print ((compile (parse-consume p)))))))
|