News for hackers. Stuff that matters.
Re:Tree Sitter and the Complications of Parsing Languages by yewenjie on Wednesday November 24, 2021 @03:34AM (#29328006)
how do you know when you have missed one single parenthesis somewhere ?
Re:Tree Sitter and the Complications of Parsing Languages by mst on Wednesday November 24, 2021 @04:27AM (#29328300)
I am very fond of things akin to vim's 'showmatch' mode where when I close a paren or block or etc. the editor highlights the opening element for a second or so and then returns to baseline.

(I have almost no -ambient- highlighting in my baseline but I know lots of people who do and still derive great value from showmatch for the feedback - from discussions with other people rainbow parens style lisp modes seem to provide a maximum overkill approach to that question but I very much prefer maximum underkill in my own tooling even while wanting to be very sure I'm not making it unduly difficult for collaborators with opposite preferences)

Re:Tree Sitter and the Complications of Parsing Languages by todd8 on Wednesday November 24, 2021 @09:24AM (#29330223)
Emacs blink-matching-paren minor mode does this. It’s quite configurable, like every other thing in Emacs.

Some of the alternatives can be found by starting at: https://www.gnu.org/software/emacs/manual/html_node/emacs/Ma...

Re:Tree Sitter and the Complications of Parsing Languages by kieckerjan on Wednesday November 24, 2021 @03:43AM (#29328061)
Does it sound presumptuous if I say that hardly ever happens? And if it does, the compiler never fails to remind me. :-)
Re:Tree Sitter and the Complications of Parsing Languages by petepete on Wednesday November 24, 2021 @04:02AM (#29328173)
There's no correct answer here, it's totally subjective.

I can sympathise with both sides; I like syntax highlighting when it's done well - when it's distracting I turn it off.

Seeing a keyword highlighted within a comment is an instant red flag - unfortunately it happens loads in Azure Data Studio (which I need to occasionally use).

Never happened in TreeSitter though.

Re:Tree Sitter and the Complications of Parsing Languages by shirleyquirk on Wednesday November 24, 2021 @04:26AM (#29328294)
parentheses matching is a surprisingly non-trivial problem. (i.e. simple counting of opening and closing parens isn't sufficient, given that quoted parens shouldn't be counted) For humans, ignoring quoted parens is maybe easier, but i would say it's a flex to assert that you can tell if (3,(g(f('('),x))) is balanced at a glance.

even if you can, surely you're wasting time and/or focus on an automatable task.

But we all have something we do 'the hard way' because it feels like more effort to relearn the task than its worth, or because we tried the easy way once and were put off by some side-effect.

paren highlighting never comes as a single unit, its always packaged with other 'helpful' tools, some subset of which will always be infuriating to someone.

Re:Tree Sitter and the Complications of Parsing Languages by kieckerjan on Wednesday November 24, 2021 @04:40AM (#29328373)
> For humans, ignoring quoted parens is maybe easier, but i would say it's a flex to assert that you can tell if (3,(g(f('('),x))) is balanced at a glance.

True, but mentally balancing parentheses is usually something that you do while writing the code: you pushpop a little stack in your head and this becomes second nature.

Mentally verifying if parentheses are balanced while reading code is hardly ever required. You can usually safely assume that they are (unless that darn compiler tells you otherwise).

Re:Tree Sitter and the Complications of Parsing Languages by shirleyquirk on Wednesday November 24, 2021 @05:32AM (#29328644)
you're probably right, difficulties when writing are mainly due to tools 'helpfully' adding a ket as soon as i type a bra.

maybe i just dont have that stack well enough built in my head--if im editing in a plugin-free vim, i do find i have to backtrack and count to make sure i've put the right number of kets at the end of a nested expression.

if i used s-expressiony instead of tab-heavy languages more often i'm sure i'd be better at it.

Re:Tree Sitter and the Complications of Parsing Languages by AkshitGarg on Wednesday November 24, 2021 @05:34AM (#29328658)
Not the OP, but my editor colors the parenthesis red in case of an imbalance [0].

I do have a minimal amount of highlighting though.

[0]: https://imgur.com/haVWset