9 releases

0.21.2 Apr 25, 2024
0.21.1 Apr 25, 2024
0.20.4 Aug 18, 2023
0.20.3 Nov 3, 2022
0.19.0 Mar 4, 2021

#6 in Text editors

Download history 10632/week @ 2024-01-24 8341/week @ 2024-01-31 7929/week @ 2024-02-07 8536/week @ 2024-02-14 10440/week @ 2024-02-21 7882/week @ 2024-02-28 8500/week @ 2024-03-06 8409/week @ 2024-03-13 8040/week @ 2024-03-20 6329/week @ 2024-03-27 8873/week @ 2024-04-03 9442/week @ 2024-04-10 12634/week @ 2024-04-17 20015/week @ 2024-04-24 18781/week @ 2024-05-01 15615/week @ 2024-05-08

68,669 downloads per month
Used in 57 crates (45 directly)

MIT license

6MB
194K SLoC

C 193K SLoC // 0.0% comments JavaScript 1.5K SLoC // 0.0% comments Scheme 162 SLoC // 0.1% comments Rust 33 SLoC

tree-sitter-rust

CI discord matrix crates npm pypi

Rust grammar for tree-sitter.

Features

  • Speed — When initially parsing a file, tree-sitter-rust takes around two to three times as long as rustc's hand-written parser.

    $ wc -l examples/ast.rs
      2157 examples/ast.rs
    
    $ rustc -Z unpretty=ast-tree -Z time-passes examples/ast.rs | head -n0
      time:   0.002; rss:   55MB ->   60MB (   +5MB)  parse_crate
    
    $ tree-sitter parse examples/ast.rs --quiet --time
      examples/ast.rs    6.48 ms        9908 bytes/ms
    

    But if you edit the file after parsing it, tree-sitter can generally update the previous existing syntax tree to reflect your edit in less than a millisecond, thanks to its incremental parsing system.

References

Dependencies

~2.7–4MB
~71K SLoC