Is the use case for this mainly IDEs or is it intended to replace traditional lexer and parser generators too?
Tree-sitter: an incremental parsing system for programming tools
31–40 of 138 posts
Re: Tree-sitter: an incremental parsing system for programming tools
#32Re: Tree-sitter: an incremental parsing system for programming tools
#33Tree-sitter is unfathomable to me. This is the grammar for Ruby: https://github.com/tree-sitter/tree-sitter-ruby/blob/master/... I find it absolutely amazing that a grammar for something as complicated as Ruby can be so concise. Less than a thousand lines. The corresponding Bison grammar is 13k lines. And I think the tree-sitter one is scannerless so also includes the lexer?! How do they do it?
This is more a function of Ruby than of tree-sitter. The tree-sitter grammars for other languages are hopefully less inscrutable. For Ruby, we basically just ported whitequark's parser [1] over to tree-sitter's grammar DSL and scanner API. [1] https://github.com/whitequark/parser
It also seems somehow to be completely declarative? How have you managed to transform Ruby parsing to be context-free? For example where's the set of what's currently a local variable so you can distinguish from method calls?
Re: Tree-sitter: an incremental parsing system for programming tools
#34Hey, Tree-sitter author here. Thanks for posting! Let me know if you have questions about the project.
Re: Tree-sitter: an incremental parsing system for programming tools
#35Here's what it looks like to call it from Rust: https://github.com/tree-sitter/tree-sitter/tree/master/lib/b... Seems like this would make it much easier to bootstrap a performant language-server. Very cool; maybe that will be my next project.
So if you're writing a tool for a single language (like a language server), it should be as easy as adding tree-sitter and tree-sitter-blah to your cargo manifest.
Re: Tree-sitter: an incremental parsing system for programming tools
#36Hey, Tree-sitter author here. Thanks for posting! Let me know if you have questions about the project.
Are there any plans to support modifying the grammar on the fly or without recompiling?
So, I would say that it's not on our near-term roadmap.
Re: Tree-sitter: an incremental parsing system for programming tools
#37Hey, Tree-sitter author here. Thanks for posting! Let me know if you have questions about the project.
Are there any plans to support modifying the grammar on the fly or without recompiling?
Re: Tree-sitter: an incremental parsing system for programming tools
#38Earlier quoted context omitted.
This is more a function of Ruby than of tree-sitter. The tree-sitter grammars for other languages are hopefully less inscrutable. For Ruby, we basically just ported whitequark's parser [1] over to tree-sitter's grammar DSL and scanner API. [1] https://github.com/whitequark/parser
I didn't mean the tree-sitter grammar was not understandable - it's very understandable - I just can't work out how to managed to find such a concise way to express grammars. Even compared to Whitequark it's 1/3 the size. What's the unique thing you do that makes it so concise? It also seems somehow to be completely declarative? How have you managed to transform Ruby parsing to be context-free? For example where's th…
To be fair, we're cheating a little bit because the Ruby grammar relies so heavily on an external scannar, which is just under 1,000 lines of C++: https://github.com/tree-sitter/tree-sitter-ruby/blob/master/...
Re: Tree-sitter: an incremental parsing system for programming tools
#39Next steps: incrementally resolve symbols and type-check?
Re: Tree-sitter: an incremental parsing system for programming tools
#40Hey, Tree-sitter author here. Thanks for posting! Let me know if you have questions about the project.