Fork me on GitHub

parcera v0.11.0 is now available with Clojurescript support 🚀

parrot 16
❤️ 12

nice, i just looking for something like this


What are some use cases for this library?


@UJRDALZA5 whenever you want to analyze clojure code without worrying about it being executed on your system (see security risks of read-string)


my use case is a script that collects translation messages on clojurescript code. i have previously used the reader but it need too many hacks because it evaluates some code... with that library i can just parse the files without evaluating it


@U0LJU20SJ i found that only top level forms have metadata, it is posible to have metadata on "all" expressions? I need line number of expersions...


@U06B73YQJ not sure what you mean. Can you give me an example ?


right now, if i execute (meta (second (parcera.core/ast somedata))) , it will return something like {:start {:row 272, :column 0}...} but if i do the same over an expression a little deeper, it always returns nil so I deduce that only top level forms has metadata...


for my use case i need that metadata on all possible forms, because im parsing cljs files and looking for (tr "some.translation.string") ... and it would be awesome have a line number of that form



"(form)=>" (:list (:symbol "tr") (:whitespace " ") (:string "\"ds.color-lightbox.title\"") (:whitespace " "))
"(meta)=>" nil
"(form)=>" (:list (:symbol "tr") (:whitespace " ") (:string "\"ds.color-lightbox.add\""))
"(meta)=>" nil


mmmm that is weird …. if I execute the code below on parcera itself all forms have metadata:

(for [node (tree-seq seq? seq (parcera/ast (slurp "./src/clojure/parcera/core.cljc")))
      :when (seq? node)
      :when (not (contains? #{:whitespace :comment} (first node)))]
  (let [code (parcera/code node)]
    [(meta node) (str (subs code 0 (min (count code) 10))
                      " ... ")]))
could you give that a try and let me know ?


strange, this code works as expected yes...


i need to investigate more...


parcera should give you metadata on all forms. However, the metadata is only attached to the parser rules, for example [:symbol "hello"] has metadata but "hello" does not. Maybe you are trying to extract it on the wrong place ?


yeah, im aware of that, I'm trying extract metadata from (:list (:symbol "tr") ...)


let me know if this turns out into a bug 😉


ok, thanks!!


im using walk/postwalk, is the unique difference to your code, maybe postwalk is doing something that i don't expect... I go to try with tree-seq...


Yep, i confirm, postwalk is stripping metadata, sorry for bothering!


oh yeah I think I heard sometime ago about that bug in postwalk. afaik there is a jira ticket for in on clojure core

Alex Miller (Clojure team)15:01:33

Take the 2020 Clojure Community Survey now! We greatly appreciate your feedback and all results will be released. Survey ends this Thu Jan 23....

👍 16

Hello Everyone! Just finished a new blog post (aka tutorial): As you may (or may not) know, my workflow platform tianoboa is also trying to be friendly to java programmers with limited (or no) clojure experience. So to try to bring the clojure experience to the java masses, I created also a REPL for java lambdas (yay!) in titanoboa's GUI. This post explains how it works and how you can use it.

👀 8

This channel is for announcing releases of new libraries and their majore updates. Please post articles, tutorials in the #news-and-articles channel. Thank you.