Strongly-typed AST types for C, auto-generated from
tree-sitter-c's node-types.json.
This crate is generated by treesitter-types and is
automatically kept up to date when a new version of the grammar crate is released.
These types have been tested by parsing the Git source code.
See the Tree-sitter project for more information about the underlying parser framework.
Example
use *;
// A minimal C hello-world program.
let src = b"\
#include <stdio.h>
int main() {
printf(\"Hello, World!\\n\");
return 0;
}
";
// Parse the source with tree-sitter and convert into typed AST.
let mut parser = new;
parser.set_language.unwrap;
let tree = parser.parse.unwrap;
let tu = from_node.unwrap;
// The translation unit has two top-level children.
assert_eq!;
// 1) The #include directive.
let PreprocInclude = &tu.children else ;
assert_eq!;
// 2) The `main` function definition with return type `int`.
let FunctionDefinition = &tu.children else ;
let PrimitiveType = &func.r#type else ;
assert_eq!;
// The declarator holds the function name and parameter list.
let FunctionDeclarator = &func.declarator else ;
assert!; // no parameters