Strongly-typed AST types for C++, auto-generated from
tree-sitter-cpp'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 nlohmann/json 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 <iostream>
int main() {
std::cout << \"Hello, World!\" << std::endl;
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.
let FunctionDefinition = &tu.children else ;
assert!; // has a function body