Rust grammar for tree-sitter (tree-sitter/tree-sitter-rust v0.24.0), for the MoonBit port of Tree-sitter (moonbit-community/treesitter).
| MoonBit | Rust |
|---|---|
| language() -> @treesitter.Language | LANGUAGE |
| node_types : String | NODE_TYPES (src/node-types.json) |
| highlights_query : String | HIGHLIGHTS_QUERY (queries/highlights.scm) |
| injections_query : String | INJECTIONS_QUERY (queries/injections.scm) |
| tags_query : String | TAGS_QUERY (queries/tags.scm) |
moon add moonbit-community/tree-sitter-rustimport {
"moonbit-community/treesitter",
"moonbit-community/tree-sitter-rust" @tree_sitter_rust,
}///|
test "parse rust" {
let language = @tree_sitter_rust.language()
let parser = @treesitter.Parser::new()
parser.set_language(language)
let source =
#|async fn abc() {}
#|
#|async fn main() {
#| let x = futures.await?;
#|}
#|
guard parser.parse(@utf8.encode(source)) is Some(tree) else {
fail("parse failed")
}
let root = tree.root_node()
assert_false(root.has_error())
assert_false(root.to_sexp().contains("ERROR"))
}let highlights_query : Stringlet injections_query : Stringlet node_types : Stringlet tags_query : StringInstall
Download zipRust grammar for tree-sitter (tree-sitter/tree-sitter-rust v0.24.0), for the MoonBit port of Tree-sitter (moonbit-community/treesitter).