This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-11-06
Channels
- # announcements (12)
- # babashka (34)
- # beginners (85)
- # calva (76)
- # cider (14)
- # clj-kondo (49)
- # cljs-dev (32)
- # clojure (418)
- # clojure-europe (3)
- # clojure-france (4)
- # clojure-italy (17)
- # clojure-losangeles (8)
- # clojure-nl (5)
- # clojure-norway (2)
- # clojure-spec (2)
- # clojure-uk (88)
- # clojuredesign-podcast (4)
- # clojurescript (49)
- # clojurex (75)
- # clr (2)
- # core-async (13)
- # cursive (6)
- # datomic (57)
- # duct (31)
- # emacs (6)
- # fulcro (25)
- # graalvm (67)
- # graphql (13)
- # hoplon (1)
- # java (6)
- # juxt (11)
- # kaocha (5)
- # keechma (2)
- # leiningen (16)
- # mount (1)
- # off-topic (19)
- # pathom (2)
- # pedestal (1)
- # re-frame (11)
- # reagent (21)
- # reitit (22)
- # rewrite-clj (1)
- # shadow-cljs (98)
- # spacemacs (5)
- # sql (16)
- # tools-deps (8)
- # vim (28)
- # xtdb (4)
edamame, the parser used in sci and hence babashka, can now parse the entire core namespaces of clojure and clojurescript. to support this, support for auto-resolve has been added. see the section under "Auto-resolve keywords" here: https://github.com/borkdude/edamame
It might be cool for edamame to create a parallel location data structure. That would solve the problem with locations for numbers. The question is how you would link the original data structure to the input. If you were using zippers you could traverse them in parallel.
with rewrite-clj you can still call sexpr
to get the sexpr. I have no plans to do a parallel universe parsing feature right now 🙂
the reason I added the locations was mostly because of unresolved symbols in babashka. there are hardly problems with number literals so the locations of those I don't need as much
or mostly when you try to analyze something and then call sexpr on nil, when the user has forgotten a value where something is expected
In aero, if an argument is a number, it would be useful to point to it after the fact.
you could point to the nearest neighbouring or wrapping element, at least it's close 🙂
the same is happening right now in clj-kondo: we do datalog linting, but we don't know the exact locations within the datalog expression because the datalog parser library doesn't return that
@dominicm hmm, spec and malli include paths into the data structures when something is wrong. using such a path into the "parallel" locations data structure, would maybe work
It does internally, but tweaks may be needed to retain the location data. I may just create "conf" on the same kind of principles.
RE edamame, how can I add to the available namespaces while reading? I'm assuming I'll need to use the dispatch table.
maybe it would help if edamame added key -> location metadata as metadata on parsed maps, so {:a 1}
<-> {:a {:row 1 :col 16}}
or something. not sure if I like it yet
RE edamame while reading: can you give me an example of what you're trying to do. I might have an idea, but example would be better to see first
there's an example in sci how to do this I think: https://github.com/borkdude/sci/blob/c8c89a63aa490106dffc3d4c856d44ba52a83e8d/src/sci/impl/parser.cljc#L18 but again, not sure if this is what you're looking for (and it's not exposed officially, so might break)
and this is in turn used by babashka: https://github.com/borkdude/babashka/blob/25844997538d84ae7e5bbcd45e7e2f00eb4d968d/src/babashka/impl/socket_repl.clj#L27
Do you have any benchmark of Edamame, comparing it to rewrite-clj(s)?
no, but since they are different in project goal it's maybe not fair to compare them
I expect edamame to be a little faster than rewrite-clj since it creates less overhead, but could be wrong
@mauricio.szabo Informally:
$ clj -Sdeps '{:deps {rewrite-clj {:mvn/version "RELEASE"}}}'
Clojure 1.10.1
user=> (require '[rewrite-clj.parser :as p])
nil
user=> (require '[ :as io])
nil
user=> (def clojure-core-src (slurp (io/file "test-resources" "clojure" "core.clj"))
)
#'user/clojure-core-src
user=> (def rewrite-clj (time (p/parse-string-all clojure-core-src)))
"Elapsed time: 284.394016 msecs"
#'user/rewrite-clj
user=> (require '[edamame.core :as edamame])
nil
user=> (def edamame (time (edamame/parse-string-all clojure-core-src {:all true :auto-resolve {:current 'clojure.core}})))
"Elapsed time: 110.019838 msecs"
#'user/edamame