From ddeb9d7adeae79e83191479706c91e9a03dc9ead Mon Sep 17 00:00:00 2001 From: jiyinyiyong Date: Sun, 4 Mar 2018 00:27:49 +0800 Subject: [PATCH] upgrade deps; more string syntax; bump 0.2.3 --- .gitattributes | 2 +- .gitignore | 2 ++ README.md | 2 +- build.boot | 2 +- coir.edn => calcit.edn | 6 +++++- data/compiled/string.cljs | 4 ++++ data/examples/string.edn | 3 +++ package.json | 2 +- polyfill/cirru_sepal/core.cljs | 4 +++- polyfill/cirru_sepal/tree_test.cljs | 7 +++++++ src/cirru_sepal/analyze.cljs | 26 +++++++++++++------------- yarn.lock | 14 +++++++------- 12 files changed, 48 insertions(+), 26 deletions(-) rename coir.edn => calcit.edn (99%) create mode 100644 data/compiled/string.cljs create mode 100644 data/examples/string.edn diff --git a/.gitattributes b/.gitattributes index 16b8717..be1819b 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,3 +1,3 @@ -coir.edn -diff linguist-generated +calcit.edn -diff linguist-generated yarn.lock -diff diff --git a/.gitignore b/.gitignore index ec2af67..6af5d42 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ /target /node_modules +.shadow-cljs/ +.cpcache/ diff --git a/README.md b/README.md index c5ea390..5c56259 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Cirru Sepal for Clojure ### API Usage [![Clojars Project](https://img.shields.io/clojars/v/cirru/sepal.svg)](https://clojars.org/cirru/sepal) ```edn -[cirru/sepal "0.2.2"] +[cirru/sepal "0.2.3"] ``` ```clojure diff --git a/build.boot b/build.boot index 78e7ea6..639d01f 100644 --- a/build.boot +++ b/build.boot @@ -9,7 +9,7 @@ :username "jiyinyiyong" :password (read-password "Clojars password: ")}])) -(def +version+ "0.2.2") +(def +version+ "0.2.3") (deftask deploy [] (comp diff --git a/coir.edn b/calcit.edn similarity index 99% rename from coir.edn rename to calcit.edn index 2c8afbc..a4f0590 100644 --- a/coir.edn +++ b/calcit.edn @@ -1212,5 +1212,9 @@ } } :saved-files {} - :configs {:storage-key "coir.edn", :extension ".cljs", :output "src", :port 6001} + :configs {:storage-key "calcit.edn", :extension ".cljs", :output "src", :port 6001} + :repl { + :alive? false + :logs {} + } } \ No newline at end of file diff --git a/data/compiled/string.cljs b/data/compiled/string.cljs new file mode 100644 index 0000000..c50d994 --- /dev/null +++ b/data/compiled/string.cljs @@ -0,0 +1,4 @@ + +(println "x") + +(println "x") diff --git a/data/examples/string.edn b/data/examples/string.edn new file mode 100644 index 0000000..e6a58a1 --- /dev/null +++ b/data/examples/string.edn @@ -0,0 +1,3 @@ + +[["println" "\"x"] + ["println" "|x"]] diff --git a/package.json b/package.json index 284aef1..a4123cd 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,6 @@ "test": "yarn compile && node target/test.js" }, "devDependencies": { - "shadow-cljs": "^2.0.126" + "shadow-cljs": "^2.2.3" } } diff --git a/polyfill/cirru_sepal/core.cljs b/polyfill/cirru_sepal/core.cljs index 7a600e0..b3b4414 100644 --- a/polyfill/cirru_sepal/core.cljs +++ b/polyfill/cirru_sepal/core.cljs @@ -138,11 +138,13 @@ (cond (= x "true") true (= x "false") false + (= x "nil") nil (= (first x) \:) (keyword (subs x 1)) (= (first x) \|) (subs x 1) + (= (first x) \") (subs x 1) (= (first x) \') `(quote ~(symbol (subs x 1))) - (re-matches #"-?\d+(\.\d+)?" x) (read-string x) (= (first x) \\) (read-string x) + (re-matches #"-?\d+(\.\d+)?" x) (read-string x) :else (symbol x)) (vector? x) (do diff --git a/polyfill/cirru_sepal/tree_test.cljs b/polyfill/cirru_sepal/tree_test.cljs index d8e3b87..bc19180 100644 --- a/polyfill/cirru_sepal/tree_test.cljs +++ b/polyfill/cirru_sepal/tree_test.cljs @@ -97,6 +97,13 @@ (read-result "doseq.cljs") (run-make-code "doseq.edn"))))) +(deftest string-test + (testing "test string syntax" + (is + (= + (read-result "string.cljs") + (run-make-code "string.edn"))))) + (def example-file " (ns a.b ) diff --git a/src/cirru_sepal/analyze.cljs b/src/cirru_sepal/analyze.cljs index c3a9823..e605265 100644 --- a/src/cirru_sepal/analyze.cljs +++ b/src/cirru_sepal/analyze.cljs @@ -2,6 +2,8 @@ (ns cirru-sepal.analyze (:require [clojure.string :as string] [cirru-sepal.core :refer [write-code]])) +(def def-names #{"def" "defonce"}) + (defn depends-on? [x y dict level] (if (contains? dict x) (let [deps (:tokens (get dict x))] @@ -12,8 +14,6 @@ (some (fn [child] (depends-on? child y dict (inc level))) deps)))) false)) -(def def-names #{"def" "defonce"}) - (defn deps-insert [acc new-item items deps-info] (if (empty? items) (conj acc new-item) @@ -26,18 +26,23 @@ (into [] (concat acc [new-item] items))) (recur (conj acc cursor) new-item (rest items) deps-info))))) -(def files-cache-ref (atom {})) - -(defn strip-property [x] (if (string/includes? x ".") (first (string/split x ".")) x)) - -(defn strip-atom [token] (if (string/starts-with? token "@") (subs token 1) token)) - (defn deps-sort [acc items deps-info] (if (empty? items) acc (let [cursor (first items), next-acc (deps-insert [] cursor acc deps-info)] (recur next-acc (into [] (rest items)) deps-info)))) +(def files-cache-ref (atom {})) + +(defn ns->path [pkg ns-part] + (-> (str pkg "." ns-part) + (string/replace (re-pattern "\\.") "/") + (string/replace (re-pattern "-") "_"))) + +(defn strip-atom [token] (if (string/starts-with? token "@") (subs token 1) token)) + +(defn strip-property [x] (if (string/includes? x ".") (first (string/split x ".")) x)) + (defn write-file [file-info] (let [ns-line (:ns file-info) definitions (:defs file-info) @@ -73,8 +78,3 @@ (comment println "after sort:" sorted-names) (comment println "generated file:" code) code)) - -(defn ns->path [pkg ns-part] - (-> (str pkg "." ns-part) - (string/replace (re-pattern "\\.") "/") - (string/replace (re-pattern "-") "_"))) diff --git a/yarn.lock b/yarn.lock index d766a9c..049fa07 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1102,20 +1102,20 @@ sha.js@^2.4.0, sha.js@^2.4.8: inherits "^2.0.1" safe-buffer "^5.0.1" -shadow-cljs-jar@1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/shadow-cljs-jar/-/shadow-cljs-jar-1.1.1.tgz#5d74383f5aff8fba25a5d00ee3c3ad035a1bd7a3" +shadow-cljs-jar@1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/shadow-cljs-jar/-/shadow-cljs-jar-1.1.2.tgz#88664fae5957a7c21554e1a33476f1c475162c92" -shadow-cljs@^2.0.125: - version "2.0.126" - resolved "https://registry.yarnpkg.com/shadow-cljs/-/shadow-cljs-2.0.126.tgz#9e6adfcbe923c5889b1dcb0f6a650b563f140373" +shadow-cljs@^2.2.3: + version "2.2.3" + resolved "https://registry.yarnpkg.com/shadow-cljs/-/shadow-cljs-2.2.3.tgz#e91c34b2eea037a136590aabcbd316301d6c0cab" dependencies: babel-core "^6.26.0" babel-preset-env "^1.6.0" mkdirp "^0.5.1" node-libs-browser "^2.0.0" readline-sync "^1.4.7" - shadow-cljs-jar "1.1.1" + shadow-cljs-jar "1.1.2" signal-exit "^3.0.2" source-map-support "^0.4.15" ws "^3.0.0"