Compare commits
7 commits
master
...
instaparse
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f8672d83f2 | ||
|
|
4bb2a75a0b | ||
|
|
568b8923ee | ||
|
|
57436a9977 | ||
|
|
988135dac0 | ||
|
|
596c684438 | ||
|
|
5f783e4d88 |
6 changed files with 82 additions and 29 deletions
1
deps.edn
1
deps.edn
|
|
@ -48,6 +48,7 @@
|
|||
com.taoensso/timbre {:mvn/version "6.0.1"}
|
||||
org.clojure/tools.logging {:mvn/version "1.1.0"}
|
||||
org.clojure/data.priority-map {:mvn/version "1.1.0"}
|
||||
instaparse/instaparse {:mvn/version "1.4.10"}
|
||||
insn/insn {:mvn/version "0.5.2"}
|
||||
org.clojure/core.rrb-vector {:mvn/version "0.1.2"}
|
||||
org.babashka/cli {:mvn/version "0.6.41"}}
|
||||
|
|
|
|||
10
project.clj
10
project.clj
|
|
@ -30,6 +30,8 @@
|
|||
[org.clojure/core.async "1.6.673"]
|
||||
[org.clojure/test.check "1.1.1"]
|
||||
[com.github.clj-easy/graal-build-time "0.1.0"]
|
||||
[rewrite-clj/rewrite-clj "1.0.699-alpha"]
|
||||
[instaparse/instaparse "1.4.10"]
|
||||
[rewrite-clj/rewrite-clj "1.1.45"]
|
||||
[insn/insn "0.5.2"]
|
||||
[org.babashka/cli "0.6.41"]]
|
||||
|
|
@ -68,7 +70,7 @@
|
|||
:feature/selmer {:source-paths ["feature-selmer"]
|
||||
:dependencies [[selmer/selmer "1.12.50"]]}
|
||||
:feature/logging {:source-paths ["feature-logging"]
|
||||
:dependencies [[com.taoensso/timbre "6.0.1"]
|
||||
:dependencies [[com.taoensso/timbre "6.0.4"]
|
||||
[org.clojure/tools.logging "1.1.0"]]}
|
||||
:feature/priority-map {:source-paths ["feature-priority-map"]
|
||||
:dependencies [[org.clojure/data.priority-map "1.1.0"]]}
|
||||
|
|
@ -95,9 +97,9 @@
|
|||
{:dependencies [[com.clojure-goes-fast/clj-async-profiler "0.5.0"]
|
||||
[com.opentable.components/otj-pg-embedded "0.13.3"]
|
||||
[nubank/matcher-combinators "3.6.0"]]}]
|
||||
:uberjar {:global-vars {*assert* false}
|
||||
:jvm-opts ["-Dclojure.compiler.direct-linking=true"
|
||||
"-Dclojure.spec.skip-macros=true"
|
||||
:uberjar {;; :global-vars {*assert* false}
|
||||
:jvm-opts [#_"-Dclojure.compiler.direct-linking=true"
|
||||
#_"-Dclojure.spec.skip-macros=true"
|
||||
"-Dborkdude.dynaload.aot=true"]
|
||||
:main babashka.main
|
||||
:aot [babashka.main]}
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@
|
|||
com.taoensso/timbre {:mvn/version "6.0.1"}
|
||||
org.clojure/tools.logging {:mvn/version "1.1.0"}
|
||||
org.clojure/data.priority-map {:mvn/version "1.1.0"}
|
||||
instaparse/instaparse {:mvn/version "1.4.10"}
|
||||
insn/insn {:mvn/version "0.5.2"}
|
||||
org.clojure/core.rrb-vector {:mvn/version "0.1.2"}
|
||||
org.babashka/cli {:mvn/version "0.6.41"}}
|
||||
|
|
|
|||
|
|
@ -3,28 +3,46 @@
|
|||
(:require [babashka.impl.patches.datafy]
|
||||
[babashka.impl.pprint]))
|
||||
|
||||
;; Enable this for scanning requiring-resolve usage:
|
||||
;; ---
|
||||
;; (def old-requiring-resolve requiring-resolve)
|
||||
|
||||
;; (defmacro static-requiring-resolve [sym]
|
||||
;; (prn :sym sym)
|
||||
;; `(old-requiring-resolve ~sym))
|
||||
|
||||
;; (alter-var-root #'requiring-resolve (constantly @#'static-requiring-resolve))
|
||||
;; (doto #'requiring-resolve (.setMacro))
|
||||
;; ---
|
||||
|
||||
;; ((requiring-resolve 'clojure.pprint/pprint) (range 20))
|
||||
|
||||
;; Enable this for detecting literal usages of require
|
||||
;; ---
|
||||
;; (def old-require require)
|
||||
|
||||
;; (defmacro static-require [& syms]
|
||||
;; (when (meta &form)
|
||||
;; (prn :require &form ))
|
||||
;; `(old-require ~@syms))
|
||||
;; (alter-var-root #'require (constantly @#'static-require))
|
||||
;; (doto #'require (.setMacro))
|
||||
;; Enable this for scanning requiring usage:
|
||||
(def enable-require-scan
|
||||
"(do
|
||||
(def old-require require)
|
||||
(def old-resolve resolve)
|
||||
|
||||
(def our-requiring-resolve (fn [sym]
|
||||
(let [ns (symbol (namespace sym))]
|
||||
(old-require ns)
|
||||
(old-resolve sym))))
|
||||
|
||||
(defn static-requiring-resolve [form _ _]
|
||||
(prn :req-resolve form :args (rest form))
|
||||
`(let [res# (our-requiring-resolve ~@(rest form))]
|
||||
res#))
|
||||
|
||||
(alter-var-root #'requiring-resolve (constantly @#'static-requiring-resolve))
|
||||
(doto #'requiring-resolve (.setMacro))
|
||||
|
||||
(defn static-require [& [&form _bindings & syms]]
|
||||
(when (meta &form)
|
||||
(prn :require &form (meta &form) *file*))
|
||||
`(old-require ~@syms))
|
||||
(alter-var-root #'require (constantly @#'static-require))
|
||||
(doto #'require (.setMacro))
|
||||
|
||||
(alter-var-root #'clojure.core/serialized-require (constantly (fn [& args]
|
||||
(prn :serialized-req args)))))
|
||||
|
||||
|
||||
|
||||
(defn static-resolve [& [&form _bindings & syms]]
|
||||
(when (meta &form)
|
||||
(prn :require &form (meta &form) *file*))
|
||||
`(old-resolve ~@syms))
|
||||
(alter-var-root #'resolve (constantly @#'static-resolve))
|
||||
(doto #'resolve (.setMacro))
|
||||
")
|
||||
|
||||
|
||||
(when (System/getenv "BABASHKA_REQUIRE_SCAN")
|
||||
(load-string enable-require-scan))
|
||||
;; ---
|
||||
|
|
|
|||
18
src/babashka/impl/instaparse.clj
Normal file
18
src/babashka/impl/instaparse.clj
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
(ns babashka.impl.instaparse
|
||||
(:require
|
||||
[instaparse.combinators-source :as source]
|
||||
[instaparse.core :as insta]
|
||||
[sci.core :as sci]))
|
||||
|
||||
(def ins (sci/create-ns 'instaparse.core))
|
||||
|
||||
(def instaparse-namespace
|
||||
{#_#_'defparser (sci/copy-var insta/defparser ins)
|
||||
#_#_'map->Parser (sci/copy-var insta/map->Parser ins)
|
||||
'parser (sci/copy-var insta/parser ins)
|
||||
#_#_'transform (sci/copy-var insta/transform ins)})
|
||||
|
||||
(def sns (sci/create-ns 'instaparse.combinators-source))
|
||||
|
||||
(def instaparse.combinators-source-namespace
|
||||
{'regexp (sci/copy-var source/regexp sns)})
|
||||
|
|
@ -346,6 +346,8 @@ Use bb run --help to show this help output.
|
|||
|
||||
(def clojure-main-ns (sci/create-ns 'clojure.main))
|
||||
|
||||
(require 'babashka.impl.instaparse)
|
||||
|
||||
(defn catvec [& xs]
|
||||
(into [] cat xs))
|
||||
|
||||
|
|
@ -476,7 +478,11 @@ Use bb run --help to show this help output.
|
|||
'clojure.tools.logging.readable
|
||||
@(resolve 'babashka.impl.logging/tools-logging-readable-namespace))
|
||||
features/priority-map? (assoc 'clojure.data.priority-map
|
||||
@(resolve 'babashka.impl.priority-map/priority-map-namespace))))
|
||||
@(resolve 'babashka.impl.priority-map/priority-map-namespace))
|
||||
true (assoc 'instaparse.core
|
||||
@(resolve 'babashka.impl.instaparse/instaparse-namespace)
|
||||
'instaparse.combinators-source
|
||||
@(resolve 'babashka.impl.instaparse/instaparse.combinators-source-namespace))))
|
||||
|
||||
(def edn-readers (cond-> {}
|
||||
features/yaml?
|
||||
|
|
@ -1132,6 +1138,13 @@ Use bb run --help to show this help output.
|
|||
(let [exit-code (run args)]
|
||||
(System/exit exit-code))))
|
||||
|
||||
;; disable graalvm bloat
|
||||
(alter-var-root #'require (constantly (fn [& args] (prn :req args))))
|
||||
(alter-var-root #'resolve (constantly (fn [& args] (prn :resolve args))))
|
||||
(alter-var-root #'requiring-resolve (constantly (fn [& args] (prn :req-resolve args))))
|
||||
(alter-var-root #'find-var (constantly (fn [& args] (prn :find-var args))))
|
||||
(alter-var-root #'find-ns (constantly (fn [& args] (prn :find-ns args))))
|
||||
|
||||
;;;; Scratch
|
||||
|
||||
(comment)
|
||||
|
|
|
|||
Loading…
Reference in a new issue