14 unstable releases (4 breaking)

0.24.0 Apr 1, 2025
0.23.2 Nov 24, 2024
0.21.2 Apr 25, 2024
0.20.4 Aug 18, 2023
0.19.0 Mar 4, 2021

#46 in Parser implementations

Download history 34520/week @ 2025-02-02 41172/week @ 2025-02-09 28749/week @ 2025-02-16 31291/week @ 2025-02-23 35455/week @ 2025-03-02 36736/week @ 2025-03-09 35463/week @ 2025-03-16 33692/week @ 2025-03-23 33735/week @ 2025-03-30 33937/week @ 2025-04-06 34430/week @ 2025-04-13 28585/week @ 2025-04-20 32176/week @ 2025-04-27 35397/week @ 2025-05-04 34218/week @ 2025-05-11 34498/week @ 2025-05-18

138,283 downloads per month
Used in 117 crates (92 directly)

MIT license

6.5MB
206K SLoC

C 205K SLoC // 0.0% comments JavaScript 1.5K SLoC // 0.0% comments Scheme 164 SLoC // 0.1% comments Rust 30 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