python-dbg
rust-sitter
python-dbg | rust-sitter | |
---|---|---|
1 | 6 | |
23 | 577 | |
- | 1.7% | |
7.7 | 5.3 | |
7 months ago | about 2 months ago | |
Python | Rust | |
MIT License | MIT License |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
python-dbg
-
Writing a Debugger from Scratch: Breakpoints
I've done something similar in Python: A Python debugger from scratch in Python
- https://github.com/parttimenerd/python-dbg/
rust-sitter
-
Writing a Debugger from Scratch: Breakpoints
This is a great series!
I noticed that the author was using https://github.com/hydro-project/rust-sitter as a parser. Which is based on https://tree-sitter.github.io/tree-sitter/. I've been hearing about Tree-sitter a lot recently, so I dug into it.
Tree-sitter is a tool for generating fast, incremental parsers. In particular, the algorithm is suited towards writing "language servers" for IDEs, which re-parse code incrementally as the user works. These kinds of incremental parsers have historically been a huge problem. It looks like Tree-sitter is an enormous practical advance in this area.
And discovering that there's a way to use Tree-sitter from Rust is fantastic. From the post:
#[rust_sitter::language]
-
Topiary: A code formatting engine leveraging Tree-sitter
Oh I totally agree with your sentiment about tree-sitter. That's why I want it to be extended in functionality. It makes so much sense to have a single place where one parser can be written and everybody benefits. Much like language servers.
Where I disagree is that IMO, tree-sitter already is very close to this ideal model. It has incremental parsing. It has great tree querying. Where it needs help is an AST facade over the raw syntax tree, which is very much feasible. rust-sitter[1] does it for instance. Tree-editing and tree construction is also very much doable. I don't think it'd have an impact on grammar construction at all. As for error recovery, I think it could function as a reparsing feature where you can drop down to a manual parser (or even a secondary grammar) that is more tolerant. Or an error recovery function that can be written in any language. tree-sitter already has the ability to use a manual lexer written in native code, so this is not such a stretch.
[1]: https://github.com/hydro-project/rust-sitter.
- GitHub - hydro-project/rust-sitter: Use Tree Sitter to parse your own languages in Rust
- Rust-sitter: Define your entire tree-sitter grammar in Rust code
- Rust-sitter: Define your entire tree-sitter grammar on idiomatic Rust
- Rust Sitter: create efficient parsers in Rust
What are some alternatives?
Crafting Interpreters - Repository for the book "Crafting Interpreters"
tree-sitter-c2rust - A fork of Tree Sitter with a pure Rust runtime for WASM support
ocamlformat - Auto-formatter for OCaml code
nvim-treesitter - Nvim Treesitter configurations and abstraction layer
tree-sitter-rust - Rust grammar for tree-sitter