7 releases

new 0.21.0 Apr 7, 2024
0.20.4 Aug 18, 2023
0.20.3 Nov 3, 2022
0.20.1 Feb 4, 2022
0.19.0 Mar 4, 2021

#10 in Text editors

Download history 4126/week @ 2023-12-21 3259/week @ 2023-12-28 5623/week @ 2024-01-04 6711/week @ 2024-01-11 8694/week @ 2024-01-18 10725/week @ 2024-01-25 7790/week @ 2024-02-01 7904/week @ 2024-02-08 9160/week @ 2024-02-15 9784/week @ 2024-02-22 8114/week @ 2024-02-29 8380/week @ 2024-03-07 8241/week @ 2024-03-14 7971/week @ 2024-03-21 6220/week @ 2024-03-28 7731/week @ 2024-04-04

31,662 downloads per month
Used in 49 crates (39 directly)

MIT license

6.5MB
198K SLoC

C 196K SLoC // 0.0% comments JavaScript 1.5K SLoC // 0.0% comments Scheme 162 SLoC // 0.1% comments Rust 31 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