Live data from Hacker News

Tree-sitter: an incremental parsing system for programming tools

github.com

131–138 of 138 posts

Re: Tree-sitter: an incremental parsing system for programming tools

#131

To me, the most impressive use of tree-sitter was an iOS text editor that uses it to parse huge JSON files / mixed language files and highlight them in a very robust way. [0][1] I’m hoping tree-sitter becomes more common like LSP and Emacs can get exact highlighting and other tools with it… [0]: https://twitter.com/simonbs/status/1352697855845273600 [1]: https://twitter.com/simonbs/status/1362492842141171720?s=21

Emacs does have a package to use tree-sitter [0]. I think emacs-lsp is aware of this highlighting backend and performs pretty well. (semantic highlighting is pretty slow for C++ with font-lock, with tree-sitter it's a breeze :)) [0]: https://github.com/ubolonton/emacs-tree-sitter

Wait what? You mean to tell me that Emacs LSP already uses tree-sitter?

Re: Tree-sitter: an incremental parsing system for programming tools

#132
post #117

Earlier quoted context omitted.

The idea is pretty awesome, but my eyes nearly rolled out of my head from the needless condescension at the beginning.

it's just how old people talk. Rob Pike speaks of syntax colouring in the same way - he quotes the Bible. I don't see it as condescension though. I think it's just a way of speaking.

I know plenty of "old people" who don't talk like this. In fact, the "old people" that I respect tend to be a lot more open-minded.

It's one thing to joke about it a little, but this is just arrogance on display with obvious derision for us children who find that traditional syntax highlighting is beneficial.

I recall reading once that Vim tabs were a crutch for people who "can't remember what they're working on". It's the same kind of arrogance and presumptiveness.

Re: Tree-sitter: an incremental parsing system for programming tools

#134
post #133

I tried looking through the docs, and couldn't find any mention of which algorithm you are using. It seems like some LR, grammar, but which kind? LALR? GLR? It seems like a very important bit of information, that's suspiciously missing.

https://tree-sitter.github.io/tree-sitter/creating-parsers#w... mentions it’s based on GLR.

Re: Tree-sitter: an incremental parsing system for programming tools

#135
post #133

I tried looking through the docs, and couldn't find any mention of which algorithm you are using. It seems like some LR, grammar, but which kind? LALR? GLR? It seems like a very important bit of information, that's suspiciously missing.

It generates LR(1) parsers, and can use GLR on an opt-in basis, for handling specific conflicts.

Re: Tree-sitter: an incremental parsing system for programming tools

#136
post #128

Wrote tree-sitter-svelte. Was a good experience. I am also writing a programming language of my own similar to TypeScript and I am using tree-sitter for the same. Its a delight to work with it. Removes a lot of the worries.

You have your code/demo on GitHub, would love to play with it.

not yet man. its in progress

Re: Tree-sitter: an incremental parsing system for programming tools

#137

Hey, Tree-sitter author here. Thanks for posting! Let me know if you have questions about the project.

I'm curious if tree-sitter can handle c++/c. I think it's supper difficult with meta programming. Without the preprocessor, I think it is not possible to parse c++ correctly.

Re: Tree-sitter: an incremental parsing system for programming tools

#138

Hey, Tree-sitter author here. Thanks for posting! Let me know if you have questions about the project.

I'm curious if tree-sitter can handle c++/c. I think it's supper difficult with meta programming. Without the preprocessor, I think it is not possible to parse c++ correctly.

We do have C and C++ grammars [1,2] but they need some love. You're right that these two languages are among the hardest to support. You could get a tree-sitter external scanner to mimic the preprocessor without too much difficulty, but you'd still run into the problem that your macro definitions might appear in another file. Parsing in general is much easier to implement and reason about if the parse result depends only on the content of the single file that you're looking at.

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

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

Post reply on HN