diff --git a/project.clj b/project.clj index b04e9e8..a782880 100644 --- a/project.clj +++ b/project.clj @@ -8,7 +8,8 @@ :target-path "target/%s" :dependencies [[org.clojure/clojure "1.10.0"] - [org.clojure/clojurescript "1.10.520"]] + [org.clojure/clojurescript "1.10.520"] + [instaparse "1.4.10"]] :plugins [[lein-doo "0.1.10"]] :cljsbuild {:builds [{:id "node-test" diff --git a/src/hopen/renderer/xf.cljc b/src/hopen/renderer/xf.cljc index f4e27a1..6f1097d 100644 --- a/src/hopen/renderer/xf.cljc +++ b/src/hopen/renderer/xf.cljc @@ -14,9 +14,7 @@ (apply f env args) (if-let [f (get-in env [:bindings f-symb])] (apply f (mapv f-eval args)) - (throw (#?(:clj Exception. - :cljs js/Error.) - (str "Function " f-symb " not found in env " env)))))) + (util/throw-exception (str "Function " f-symb " not found in env " env))))) :else element))] (f-eval element))) diff --git a/src/hopen/syntax/util.cljc b/src/hopen/syntax/util.cljc new file mode 100644 index 0000000..e582f75 --- /dev/null +++ b/src/hopen/syntax/util.cljc @@ -0,0 +1,10 @@ +(ns hopen.syntax.util + (:require [clojure.string :as str])) + +(defn re-quote + "Escapes characters in the string that are not safe to use in a regex. + Function ported to Clojure from https://github.com/google/closure-library/blob/0257667129eded0cb9b86b4701e50c986b5db648/closure/goog/string/string.js#L1016" + [s] + (-> s + (str/replace #"[-()\[\]{}+?*.$\^|,:#" "\\<%%>"))