What does HackerNews think of tree-sitter?

An incremental parsing system for programming tools

Language: Rust

#13 in C
#3 in Parsing
#32 in Rust
What do you think about treesitter? https://github.com/tree-sitter/tree-sitter

The idea is to sync changes in the text to a tree structure, then have all the structure manipulation functions built on top of it. See the gif here for a visual representation: https://github.com/nvim-treesitter/playground

Emacs 29 also aims to introduce experimental support for tree-sitter[1], although it will probably be hidden behind a configure-flag.

This should enable us to create better, faster parsers for popular languages where the Emacs-support so far has not been that great.

So yeah I second that. Emacs 29 is going to be a great release!

[1] https://github.com/tree-sitter/tree-sitter

I could see 1 and 3 not being too hard to build using treesitter[0] Too bad, I don't have time to build it

[0] https://github.com/tree-sitter/tree-sitter

EDIT: Wilfred IS the original author [3]; my apologies.

Not to discredit Wilfred (it looks like he's taken over the project as the maintainer), but, based on the historical contributions [1], it looks like it was originally developed by Max Brunsfeld, who also created Tree-sitter. [2]

[1]: https://github.com/Wilfred/difftastic/graphs/contributors

[2]: https://github.com/tree-sitter/tree-sitter

[3]: https://github.com/Wilfred/difftastic/commit/958033924a2dea7...

Treesitter[0] maybe? Although that may also be built into VS Code too, I've just never seen it mentioned anywhere.

0. https://github.com/tree-sitter/tree-sitter

> Does GitHub currently use tree-sitter for syntax highlighting?

For some languages, yes. https://news.ycombinator.com/item?id=26227214

> If yes, are the libraries open-source?

They are! tree-sitter itself is open-source [1], as are all of the language parsers we've listed on the homepage [2]. The syntax highlighting support is documented here [3].

[1] https://github.com/tree-sitter/tree-sitter

[2] https://tree-sitter.github.io/tree-sitter/#available-parsers

[3] https://tree-sitter.github.io/tree-sitter/syntax-highlightin...

I like the principle of "make unauthorized states unrepresentable", but it makes me nervous, or at least evokes a nuance that is well addressed by https://github.com/tree-sitter/tree-sitter

> Robust enough to provide useful results even in the presence of syntax errors

Especially when it comes to human-generated input (but even outside of that) it is beneficial to have a representation for unauthorized states, so long as you can easily detect that that's what you're representing. That allows you to better report errors, or try to mitigate them.

In other words, don't forget to have an https://wiki.c2.com/?EscapeHatch

> First, TextMate / Sublime style syntax highlighting is not really all that great. It is quite slow, largely because it grinds through a lot of regular expressions with captures, and it is also not very precise.

The tree-sitter framework provides a pretty good engine for syntax highlight:

https://github.com/tree-sitter/tree-sitter