calva

Wednesdays you might find @U0ETXRFEW in the Gather Calva space. Invite is https://gather.town/invite?token=GZqrm7CR and the password is `Be kind`.
2020-11-01T00:59:36.064400Z

yeah, i kept scanning for list and then realized it was probably named something else. it is the one for s-expression right?

pez 2020-11-01T12:35:41.071300Z

I just ran into a decision regarding syntax parsing of numbers in Calva. Generally I want to stay as close to https://clojure.org/reference/reader as possible. However what to do with something like 0xg? Currently there are three interpretations at play in Calva: 1. The syntax highlighter treats as &lt;digit&gt;&lt;symbol&gt; 2. Current Paredit treats it as &lt;junk&gt; (mainly do to a bug that I am just fixing) 3. Paredit in my https://github.com/BetterThanTomorrow/calva/compare/parsing-issues treats it the same as the syntax highlighter. 4. The Reader treats it as an illegal number. The keen eye can see that 1 <=> 3 and 2 <=> 4. Heaving rubber ducked this now, I'm leaning towards that it makes most sense to stick to my ”stay close to The Reader" rule of thumb...

2020-11-01T12:40:29.072200Z

@pez possibly a similar situation, i chose to try to treat \o378 as an octal character even though the last digit is out of range: https://github.com/sogaiu/tree-sitter-clojure/blob/master/grammar.js#L142-L150

2020-11-01T12:41:17.073400Z

for 0xg if you anticipate that arising mostly because of being a typo, possibly it makes sense to treat it as a number

pez 2020-11-01T12:42:30.074300Z

Yes, you seem to have arrived at the same decision there.

pez 2020-11-01T12:43:22.075100Z

> for `0xg` if you anticipate that arising mostly because of being a typo, possibly it makes sense to treat it as a number Depends... Maybe it is more helpful as a user to see that it is not parsed as a number?

2020-11-01T12:43:49.075500Z

if it's possible to detect errors reliably and show them as such i agree

2020-11-01T12:44:15.076Z

i don't think i get to choose that for tree-sitter unfortunately

pez 2020-11-01T12:44:32.076400Z

I'm not sure it is possible. It is certainly easier to allow more hex digits...

2020-11-01T12:45:09.076900Z

regarding showing errors, i like to think that with clj-kondo around, i can rely on that 🙂

pez 2020-11-01T12:45:58.077700Z

Does it have a linter for illegal numbers? If so I could choose the easy way out here. 😃

2020-11-01T12:46:14.078Z

i'm not sure actually -- perhaps i should do some tests

borkdude 2020-11-01T12:46:31.078200Z

probably it will crash the reader

2020-11-01T12:46:48.078500Z

it worked for \o378 fwiw

2020-11-01T12:46:58.078700Z

$ clj-kondo --lint bad-octal.clj 
bad-octal.clj::: error: Invalid digit 8 in unicode character \o378.
linting took 5ms, errors: 1, warnings: 0

2020-11-01T12:47:29.079Z

...and 0xg:

$ clj-kondo --lint bad-hex.clj 
bad-hex.clj:1:3: error: Invalid number: 0xg.
linting took 3ms, errors: 1, warnings: 0

2020-11-01T12:47:45.079200Z

great work, @borkdude 🙂

borkdude 2020-11-01T12:48:15.079500Z

thank @bronsa for his work on tools.reader

2020-11-01T12:48:26.079800Z

thanks @bronsa 🙂

2020-11-01T12:48:49.080100Z

ah, i suppose it's not surprising he is not here

pez 2020-11-01T13:09:53.081100Z

Does it report the right position in the file for you? To me it always reports 1,3 regardless.

pez 2020-11-01T13:11:14.082200Z

I realize that that is why I assumed that clj-kondo wouldn't save the day. Didn't see the squiggle, which is under (ns in my file. 😃

pez 2020-11-01T13:14:07.083700Z

Further, in the precense of a 0xg in the file, all other linting errors disappear . Maybe this is what you meant by "it will crash the reader”, @borkdude?

borkdude 2020-11-01T13:14:20.084Z

Yeah, it does so when it doesn't know the location because of some bad error handling. It can be fixed probably, feel free to paste an issue

pez 2020-11-01T17:25:25.084200Z

I decided to go for something as close to the Reader as I could. So soon both syntax highlighting and Paredit will treat things like 0xg as one, invalid, numeric token. (Same for something like 078.) Also soon Calva will actually start to treat numeric literals and some other Clojure text much more correctly. Follow this PR for progress (and please install the VSIX to help test the changes ❤️): • PR: https://github.com/BetterThanTomorrow/calva/pull/838 • VSIX: https://8550-125431277-gh.circle-artifacts.com/0/tmp/artifacts/calva-2.0.131-parsing-issues-6af8b95e.vsix

❤️ 1
pez 2020-11-01T22:22:40.084900Z

I actually got through the whole list supplied by @sogaiu (I think/hope). https://8580-125431277-gh.circle-artifacts.com/0/tmp/artifacts/calva-2.0.131-parsing-issues-f8e3c551.vsix. Please help putting it to some testing, Calva-friends.