C grammar for tree-sitter (tree-sitter/tree-sitter-c v0.24.2), 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) |
| highlight_query : String | HIGHLIGHT_QUERY (queries/highlights.scm) |
| tags_query : String | TAGS_QUERY (queries/tags.scm) |
moon add moonbit-community/tree-sitter-cimport {
"moonbit-community/treesitter",
"moonbit-community/tree-sitter-c" @tree_sitter_c,
}///|
test "parse c" {
let language = @tree_sitter_c.language()
let parser = @treesitter.Parser::new()
parser.set_language(language)
let source =
#|// this is a macro
#|GIT_INLINE(int *) x = 5;
#|
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 highlight_query : Stringlet node_types : Stringlet tags_query : StringInstall
Download zipC grammar for tree-sitter (tree-sitter/tree-sitter-c v0.24.2), for the MoonBit port of Tree-sitter (moonbit-community/treesitter).