Expand description
This crate provides C language support for the tree-sitter parsing library.
Typically, you will use the LANGUAGE constant to add this language to a
tree-sitter Parser, and then use the parser to parse some code:
let code = "int main(void) {\n return 0;\n}\n";
let mut parser = tree_sitter::Parser::new();
let language = tree_sitter_c::LANGUAGE;
parser
.set_language(&language.into())
.expect("Error loading C parser");
let tree = parser.parse(code).unwrap();
assert!(!tree.root_node().has_error());The parser uses the ABI of the WillBooster/tree-sitter generator, which upstream tree-sitter runtimes reject. Use
the willbooster-tree-sitter runtime that this crate is tested with, 28.0.1.
Constantsยง
- LANGUAGE
- The tree-sitter
LanguageFnfor this grammar. - NODE_
TYPES - The content of the
node-types.jsonfile for this grammar.