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 10535/week @ 2024-01-26 7374/week @ 2024-02-02 8083/week @ 2024-02-09 9817/week @ 2024-02-16 9013/week @ 2024-02-23 8154/week @ 2024-03-01 8731/week @ 2024-03-08 7794/week @ 2024-03-15 7822/week @ 2024-03-22 6810/week @ 2024-03-29 9230/week @ 2024-04-05 9321/week @ 2024-04-12 15799/week @ 2024-04-19 20279/week @ 2024-04-26 19031/week @ 2024-05-03 16605/week @ 2024-05-10

73,206 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.8–4MB
~72K SLoC