Fork me on GitHub
#tree-sitter
<
2020-02-21
>
sogaiu10:02:49

btw, i've fetched quite a few github repositories containing clj code and run one of the grammars over the contained clj and cljc files to see how it does.

sogaiu10:02:40

it's helped to identify a few weak spots and am working on seeing if they can be attended to.

sogaiu10:02:17

it's also brought up a number of points regarding actual usage vs docs on http://clojure.org.

sogaiu10:02:34

e.g. if you read: https://clojure.org/reference/reader#_symbols (also see keyword section) -- you might think that putting # in a symbol or keyword is not a good idea (it's not listed as an allowed character). it turns out that music-oriented code seems to like using it in keywords (e.g. :A#) and there are a few other places # seems to be used in keywords. apart from what the docs say, i think use of # in a symbol is a potential problem because of the use of # in gensyms -- at least i think it may be likely to confuse tooling. another thing is use of slashes. there are some folks who seem to like to use slashes in keywords for: urls, file paths, etc. -- this seems to be in conflict with the aforementioned page. another slash usage that comes up is :/. (i'm inclined toward allowing my-ns// to refer to something defined as / in my-ns.)

sogaiu10:02:35

i'm not terribly surprised to find these things -- just wondering what to do about them 🙂

sogaiu10:02:33

one idea is to have a grammar that is very strict -- you could use this as a kind of linter may be (not sure if tree-sitter would require some tweaking) -- and another that is more lenient.

pez11:02:40

Does clj-kondo warn about any of those?

sogaiu12:02:22

i've been running clj-kondo on some of the files that were fetched. sometimes clj-kondo gives errors, sometimes not. regarding :/ i learned that in june of last year, there was a discussion and iiuc it's now considered legal -- though i'm not quite sure how to interpret the conversation. it did seem to lead to changes in cljs though.

sogaiu12:02:36

i've also tested things at the repl -- the repl is more permissive than the docs, and sometimes load-file is more permissive than the repl.

sogaiu12:02:27

i'm not going to take the repl as the source of truth, though i think if something manages to get in through the repl, that should be considered a factor.