This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-11-07
Channels
- # announcements (37)
- # babashka (28)
- # beginners (104)
- # calva (28)
- # cider (32)
- # clj-kondo (35)
- # cljs-dev (4)
- # cljsrn (3)
- # clojure (35)
- # clojure-conj (4)
- # clojure-dev (57)
- # clojure-europe (4)
- # clojure-france (6)
- # clojure-gamedev (1)
- # clojure-germany (1)
- # clojure-hamburg (2)
- # clojure-italy (7)
- # clojure-nl (4)
- # clojure-spec (9)
- # clojure-uk (11)
- # clojuredesign-podcast (2)
- # clojurescript (36)
- # clojurex (48)
- # core-async (6)
- # cursive (12)
- # data-science (1)
- # datomic (21)
- # defnpodcast (7)
- # duct (1)
- # events (1)
- # fulcro (56)
- # graalvm (30)
- # graphql (5)
- # jobs (1)
- # joker (21)
- # keechma (1)
- # leiningen (4)
- # off-topic (109)
- # parinfer (20)
- # pathom (27)
- # re-frame (4)
- # shadow-cljs (80)
- # spacemacs (18)
- # sql (32)
- # testing (2)
- # tools-deps (32)
- # vim (20)
Thanks! I'm using rewrite-cljs to parse Clojure sourcecode, but sometimes things get slow, so I'm seeing if there are any alternatives, even if I have to "hack" a little bit the library đŸ™‚
@mauricio.szabo I just added support for reading auto-resolved namespaced maps, so I think edamame should be pretty complete as a full code reader now... although I've only tested it on clojure/CLJS core.clj(s) and my own babashka / sci scripts
It probably needs more testing if it's going to be used in IDEs to parse any random clojure code
The thing you might find with IDEs is partial parsing. Depending on where you use it.
@dominicm are you suggesting that edamame might be used for partial parsing? I guess that can work given the right options
@dominicm one option for the location problem is to wrap non-metadatable items in a wrapper, if the caller is willing to unpack those during processing
you'd have to do a walk over the data structure to make it into normal EDN, but you get a chance to look at the locations before that. yes, it's rewrite-clj like, but optional and maybe configurable
or storing the locations of the keys + vals as arrays of locations on the metadata on maps/vectors
Yes, partial parsing is really complicated. Currently, my code just ignores things that are not valid, and keep trying to find something. It can (and do!) generate some really bizarre trees
@mauricio.szabo i'm running into the "how to deal with not-valid code" issue now. was hoping to have some way to cope with it using rewrite-clj, but i don't find anything may be the tree-sitter stuff is worth examining -- apparently there is already a clojure grammar for it (https://github.com/oakmac/tree-sitter-clojure) and iiuc, atom has tree-sitter built-in now.
@UG1C3AD5Z What kind of code are you having trouble, and what did you expect?
i'm sending the content of an editor buffer to an external program to "detect the current expression". e.g. in the editor buffer, if i have:
(-> (rz/of-string "(+ 1 1)")
rz/down
rz/right
rz/string)
and want to try something different for a moment:
(-> (rz/of-string "(+ 1 1)")
rz/down
rz/tag) ; request detection of expression here
rz/right
rz/string)
the latter code is not going to be parseable by rewrite-clj if i send the entire editor buffer content.The thing is, what should happen here?
Maybe automatically remove the last paren?
one thought is to send text up to the cursor position plus some number of appropriate closing delimiters. don't know if that's really a good idea or how easy it would be to implement (e.g. it's not always going to be a right-paren that i need).
Like, (+ 1 [ (+ 2 3))
, my core currently detects (+ 2 3)
as the only "valid" part of the code...
The problem is that it also detects it as a "top-level" :face_with_rolling_eyes: