tree-sitter

tree-sitter fun
2020-02-21T10:27:49.057700Z

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.

2020-02-21T10:29:40.058900Z

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

2020-02-21T10:30:17.059600Z

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

2020-02-21T10:39:34.065800Z

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.)

2020-02-21T10:40:35.066300Z

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

2020-02-21T10:41:33.067300Z

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.

pez 2020-02-21T11:47:40.068100Z

Does clj-kondo warn about any of those?

2020-02-21T12:15:22.070200Z

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.

2020-02-21T12:16:36.071100Z

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.

2020-02-21T12:17:27.072100Z

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.