1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//! Strongly-typed AST types for C, auto-generated from
//! [`tree-sitter-c`](https://docs.rs/tree-sitter-c)'s `node-types.json`.
//!
//! This crate is generated by [`treesitter-types`](https://docs.rs/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](https://github.com/git/git) source code.
//!
//! See the [Tree-sitter](https://tree-sitter.github.io/tree-sitter/) project for more
//! information about the underlying parser framework.
//!
//! # Example
//!
//! ```
//! use treesitter_types_c::*;
//!
//! // 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 = tree_sitter::Parser::new();
//! parser.set_language(&tree_sitter_c::LANGUAGE.into()).unwrap();
//! let tree = parser.parse(src, None).unwrap();
//! let tu = TranslationUnit::from_node(tree.root_node(), src).unwrap();
//!
//! // The translation unit has two top-level children.
//! assert_eq!(tu.children.len(), 2);
//!
//! // 1) The #include directive.
//! let TranslationUnitChildren::PreprocInclude(include) = &tu.children[0] else {
//! panic!("expected a preproc include");
//! };
//! assert_eq!(include.span.start.row, 0);
//!
//! // 2) The `main` function definition with return type `int`.
//! let TranslationUnitChildren::FunctionDefinition(func) = &tu.children[1] else {
//! panic!("expected a function definition");
//! };
//! let TypeSpecifier::PrimitiveType(return_type) = &func.r#type else {
//! panic!("expected a primitive type");
//! };
//! assert_eq!(return_type.text(), "int");
//!
//! // The declarator holds the function name and parameter list.
//! let Declarator::FunctionDeclarator(decl) = &func.declarator else {
//! panic!("expected a function declarator");
//! };
//! assert!(decl.parameters.children.is_empty()); // no parameters
//! ```
pub use tree_sitter_c;
pub use tree_sitter;
pub use ;
pub use *;