#tree-sitter #language #parser #html

bin+lib tree-sitter-parsers

Rust 项目预安装多种语言的 tree-sitter 解析器

4 个版本

0.0.5 2021 年 9 月 15 日
0.0.4 2021 年 9 月 13 日
0.0.3 2021 年 9 月 11 日
0.0.2 2021 年 9 月 11 日
0.0.1 2021 年 9 月 10 日

#2136过程宏

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

52 每月下载量
rust-diagnostics 中使用

Apache-2.0 或 MIT

156MB
4.5M SLoC

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

包含 (静态库, 2KB) tree-sitter-elm-4.5.0/parser.lib

Tree-sitter 解析器

该包 tree-sitter-parsers 预安装了多种编程语言的 tree-sitter 解析器。

用法

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)))");
}

在上面的 parse 函数调用中,代码字符串是第一个参数,编程语言字符串是第二个参数。然后作为结果,将返回 tree-sitter::Tree,我们可以通过 tree-sitter 的 API 访问它。

该包也可以作为命令运行

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

其中 <file><ext> 分别是文件名和扩展名。该命令将输入参数文件转换为对应的文件扩展名 AST。

支持的编程语言列表

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

依赖项

~2.7–4MB
~71K SLoC