#tree-sitter #language #parser #html

bin+lib tree-sitter-parsers

Preinstallation of tree-sitter parsers of multiple languages for Rust projects

4 releases

0.0.5 Sep 15, 2021
0.0.4 Sep 13, 2021
0.0.3 Sep 11, 2021
0.0.2 Sep 11, 2021
0.0.1 Sep 10, 2021

#2136 in Procedural macros

Download history 9/week @ 2024-03-10 4/week @ 2024-03-17 1/week @ 2024-03-24 22/week @ 2024-03-31 1/week @ 2024-04-07 8/week @ 2024-04-21 2/week @ 2024-04-28 1/week @ 2024-05-26

52 downloads per month
Used in rust-diagnostics

Apache-2.0 OR MIT

156MB
4.5M SLoC

C 4.5M SLoC // 0.0% comments JavaScript 22K SLoC // 0.0% comments C++ 4.5K SLoC // 0.0% comments Scheme 1.5K SLoC // 0.1% comments TypeScript 1K SLoC // 0.0% comments Java 849 SLoC // 0.0% comments Rust 665 SLoC // 0.2% comments Solidity 657 SLoC // 0.1% comments Scala 284 SLoC // 0.2% comments Kotlin 139 SLoC C# 12 SLoC Python 12 SLoC // 0.6% comments Shell 11 SLoC // 0.2% comments Ruby 3 SLoC

Contains (static library, 2KB) tree-sitter-elm-4.5.0/parser.lib

Tree-sitter parsers

The crate tree-sitter-parsers preinstalls the tree-sitter parsers for a number of programming languages.

Usage:

use tree_sitter_parsers::parse;

fn main() {
    let tree = parse("fn main() { }", "rust");
    println!("{}", tree.root_node().to_sexp());
    assert_eq!(tree.root_node().to_sexp(), "(source_file (function_item name: (identifier) parameters: (parameters) body: (block)))");
}

In the above invocation of parse function, a string of the code is the first argument, and a string of the programming language is the second argument. Then as a result, the tree-sitter::Tree will be returned, where we can access it through the tree-sitter's API.

The crate can also be run as a command:

tree-sitter-parser <file1>.<ext1> [ <file2>.<ext2> ... ]

where <file> and <ext> are respectively the filename and extension names. The command will turn the input argument files into the ASTs corresponding to the file extension names.

The list of supported languages are:

bash
c
cpp
c sharp
css
elm
go
haskell
html
java
javascript
kotlin
lua
php
python
ruby
rust
scala
solidity
verilog
yaml

Dependencies

~2.7–4MB
~71K SLoC