Bump sci: namespaces
This commit is contained in:
parent
87accff420
commit
3e0d464bfe
4 changed files with 21 additions and 21 deletions
2
sci
2
sci
|
|
@ -1 +1 @@
|
||||||
Subproject commit 4b4b8f49b51c5c471591fe484bdc80a58dc5f8ea
|
Subproject commit d91bf4bf1b831de58a4980379558aed6ce28a641
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
[clojure.java.io :as io]
|
[clojure.java.io :as io]
|
||||||
[clojure.string :as str]
|
[clojure.string :as str]
|
||||||
[clojure.tools.reader.reader-types :as r]
|
[clojure.tools.reader.reader-types :as r]
|
||||||
[sci.impl.interpreter :refer [opts->ctx eval-edn-vals]]
|
[sci.impl.interpreter :refer [opts->ctx eval-form]]
|
||||||
[sci.impl.parser :as parser]))
|
[sci.impl.parser :as parser]))
|
||||||
|
|
||||||
(set! *warn-on-reflection* true)
|
(set! *warn-on-reflection* true)
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
(println))
|
(println))
|
||||||
:read (fn [_request-prompt request-exit]
|
:read (fn [_request-prompt request-exit]
|
||||||
(if (r/peek-char in) ;; if this is nil, we reached EOF
|
(if (r/peek-char in) ;; if this is nil, we reached EOF
|
||||||
(let [v (parser/parse-next in #{:bb})]
|
(let [v (parser/parse-next in #{:bb} {:current (-> sci-ctx :env deref :current-ns)})]
|
||||||
(if (or (identical? :repl/quit v)
|
(if (or (identical? :repl/quit v)
|
||||||
(identical? :repl/exit v)
|
(identical? :repl/exit v)
|
||||||
(identical? :edamame.impl.parser/eof v))
|
(identical? :edamame.impl.parser/eof v))
|
||||||
|
|
@ -32,18 +32,20 @@
|
||||||
v))
|
v))
|
||||||
request-exit))
|
request-exit))
|
||||||
:eval (fn [expr]
|
:eval (fn [expr]
|
||||||
(let [ret (eval-edn-vals (update sci-ctx
|
(let [ret (eval-form (update sci-ctx
|
||||||
:env
|
:env
|
||||||
(fn [env]
|
(fn [env]
|
||||||
(swap! env assoc
|
(swap! env update-in [:namespaces 'clojure.core]
|
||||||
'*1 *1
|
assoc
|
||||||
'*2 *2
|
'*1 *1
|
||||||
'*3 *3
|
'*2 *2
|
||||||
'*e *e)
|
'*3 *3
|
||||||
env))
|
'*e *e)
|
||||||
[expr])]
|
env))
|
||||||
|
expr)]
|
||||||
ret))
|
ret))
|
||||||
:need-prompt (fn [] true))))
|
:need-prompt (fn [] true)
|
||||||
|
:prompt #(printf "%s=> " (-> sci-ctx :env deref :current-ns)))))
|
||||||
|
|
||||||
(defn start-repl! [host+port sci-opts]
|
(defn start-repl! [host+port sci-opts]
|
||||||
(let [parts (str/split host+port #":")
|
(let [parts (str/split host+port #":")
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,6 @@
|
||||||
[clojure.java.shell :as shell]
|
[clojure.java.shell :as shell]
|
||||||
[clojure.string :as str]
|
[clojure.string :as str]
|
||||||
[sci.core :as sci])
|
[sci.core :as sci])
|
||||||
(:import [sun.misc Signal]
|
|
||||||
[sun.misc SignalHandler])
|
|
||||||
(:gen-class))
|
(:gen-class))
|
||||||
|
|
||||||
(set! *warn-on-reflection* true)
|
(set! *warn-on-reflection* true)
|
||||||
|
|
@ -259,9 +257,9 @@ Everything after that is bound to *command-line-args*."))
|
||||||
(let [expr (if file (read-file file) expression)]
|
(let [expr (if file (read-file file) expression)]
|
||||||
(if expr
|
(if expr
|
||||||
(loop [in (read-next *in*)]
|
(loop [in (read-next *in*)]
|
||||||
(let [ctx (update ctx :bindings assoc (with-meta '*in*
|
(let [ctx (update-in ctx [:namespaces 'user] assoc (with-meta '*in*
|
||||||
(when-not stream?
|
(when-not stream?
|
||||||
{:sci/deref! true})) in)]
|
{:sci/deref! true})) in)]
|
||||||
(if (identical? ::EOF in)
|
(if (identical? ::EOF in)
|
||||||
[nil 0] ;; done streaming
|
[nil 0] ;; done streaming
|
||||||
(let [res [(let [res (sci/eval-string expr ctx)]
|
(let [res [(let [res (sci/eval-string expr ctx)]
|
||||||
|
|
|
||||||
|
|
@ -36,13 +36,13 @@
|
||||||
(sh "bash" "-c"
|
(sh "bash" "-c"
|
||||||
"lsof -t -i:1666"))))))
|
"lsof -t -i:1666"))))))
|
||||||
(is (str/includes? (socket-command '(+ 1 2 3))
|
(is (str/includes? (socket-command '(+ 1 2 3))
|
||||||
"bb=> 6"))
|
"user=> 6"))
|
||||||
(testing "ctrl-d exits normally, doesn't print nil"
|
(testing "ctrl-d exits normally, doesn't print nil"
|
||||||
(is (str/ends-with? (:out (sh "bash" "-c"
|
(is (str/ends-with? (:out (sh "bash" "-c"
|
||||||
(if mac? ;; mac doesn't support -q
|
(if mac? ;; mac doesn't support -q
|
||||||
"echo \"(inc 1336)\" | nc 127.0.0.1 1666"
|
"echo \"(inc 1336)\" | nc 127.0.0.1 1666"
|
||||||
"echo \"(inc 1336)\" | nc -q 1 127.0.0.1 1666")))
|
"echo \"(inc 1336)\" | nc -q 1 127.0.0.1 1666")))
|
||||||
"1337\nbb=> ")))
|
"1337\nuser=> ")))
|
||||||
(testing "*in*"
|
(testing "*in*"
|
||||||
(is (str/includes? (socket-command "*in*")
|
(is (str/includes? (socket-command "*in*")
|
||||||
"[1 2 3]")))
|
"[1 2 3]")))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue