Fork me on GitHub
#calva
<
2020-03-06
>
sogaiu08:03:32

so here's a fun one: https://github.com/leonoel/plop/blob/master/src/plop/gcc.cljc#L44 this one popped up as the only use of case with a (def) in it across testing a large sample of files. more than one editor colors the def as if it were a def form. not worth trying to handle perhaps? 🙂

sogaiu08:03:49

actually, there was a second example, but it's from the same repository.

pez08:03:25

What's that (def) doing there?

sogaiu08:03:25

curious about the general question of what to do about def-like forms within defmacro though.

sogaiu08:03:36

it's part of the case.

pez08:03:28

Ah, I see. But what is the result of evaluating it? I guess I have the same question about many of the cases there. I don't think I follow the syntax....

sogaiu08:03:04

> The test-constants are not evaluated.

pez08:03:22

> not worth trying to handle perhaps? I predict it would be extremely hard to handle using tmLanguage grammar. And a real solution would probably involve macro expansion...

sogaiu08:03:31

i'm not sure tree-sitter is going to fare any better here 🙂

pez08:03:30

We can handle this particular case (hehe) in Calva Highlight, if we choose to. It could serve an educational purpose to see that those are constants, but there are so many things we could do with our time! 😃

sogaiu08:03:36

yes, good point. i think it's good to enumerate (and briefly look at each point), but need to consider what things to focus on in the context of what else there is.

pez08:03:29

You are collecting material for a super interesting series of blog posts, me thinks.

sogaiu08:03:54

lol, i am collecting for sure.

sogaiu09:03:44

i'm getting Error: invalid pattern in look-behind for:

'match': '(?<=(^|\\s|\\(|\\[|\\{))(true|false)(?=(\\s|,|\\)|\\]|\\}|\\^|$))'
for the tm grammar when i do "run package specs" in atom. in node, the following works:
'true'.match(/(?<=(^|\s|\(|\[|\{))(true|false)(?=(\s|,|\)|\]|\}|\^|$))/)
any ideas as to what i might be doing wrong? for reference, the error appears to originate from the first-mate package that atom uses.

sogaiu09:03:28

ah, here it is (for look-behinds...):

different character length is allowed in top level alternatives only.
https://github.com/kkos/oniguruma/blob/master/doc/RE so changing to:
'match': '(?<=^|\\s|\\(|\\[|\\{)(true|false)(?=(\\s|,|\\)|\\]|\\}|\\^|$))'
works...sad that i had to remove a pair of parens 😞

sogaiu09:03:48

(til, first-mate uses oniguruma for tm grammars -- i guess it shouldn't be a problem in vscode because of what's mentioned here: https://code.visualstudio.com/api/language-extensions/syntax-highlight-guide#textmate-grammars)

hindol09:03:44

Calva sometimes prints sudden newlines within pprint output. When I build an uberjar and run the same thing in console, the same issue is not there.

hindol09:03:57

This might be a REPL thing as well, don't know.

pez10:03:52

@sogaiu To my experience it has depended on things what works in node or not. I think they have upgraded the regex capabilities in vscode lately by upgrading to a newer Electron. It's is actually a todo to investigate that and see if something can be won by making Calva require a newer version of VS Code.

sogaiu11:03:38

thanks for the info!

sogaiu11:03:35

iiuc, atom uses oniguruma only for textmate grammars. is it possible vscode does the same? the page linked above has the text: > TextMate grammars are a structured collection of Oniguruma regular expressions and are typically written as a plist or JSON. but i suppose that's not actually saying that vscode uses oniguruma...

pez11:03:06

I have always assumed it uses oniguruma. At least it uses something different than what vscode uses for the extension code's regex needs. I used to not be able to have things like \p{lL} in the extension, but I could add it to the tmLanguage grammar w/o complaints. (Now it seems \p works in the extension too, at least noone has complained since I added it to the token cursor's scanner.)

pez11:03:30

Also, the process for updating the tmLanguage grammar's of the vscode built-in grammars is that you first get your PR merged into the Atom repo, then tell the vscode team. Surely, it must mean that whatever regex engine Atom uses, vscode also uses, right? (Which begs the question: Does Atom use Oniguruma? But anyway 😄 )

pez11:03:18

BTW, it took me half a year to get any response on my PR to the Atom repo, which is why I moved things into Calva instead. Now that is merged there, but Calva's grammar has evolved quite a bit beyond, haha.

sogaiu12:03:49

the info on oniguruma in atom i found was from: https://discuss.atom.io/t/regular-expression-lookaround-support-in-find/12400/2 -- ofc that's 6 years ago. off to sleep -- ttyl!