treesitter_types_lua/lib.rs
1//! Strongly-typed AST types for Lua, auto-generated from
2//! [`tree-sitter-lua`](https://docs.rs/tree-sitter-lua)'s `node-types.json`.
3//!
4//! This crate is generated by [`treesitter-types`](https://docs.rs/treesitter-types) and is
5//! automatically kept up to date when a new version of the grammar crate is released.
6//!
7//! See the [Tree-sitter](https://tree-sitter.github.io/tree-sitter/) project for more
8//! information about the underlying parser framework.
9//!
10//! # Example
11//!
12//! ```
13//! use treesitter_types_lua::*;
14//!
15//! // A minimal Lua hello-world program.
16//! let src = b"\
17//! function greet(name)
18//! print(\"Hello, \" .. name .. \"!\")
19//! end
20//!
21//! greet(\"World\")
22//! ";
23//!
24//! // Parse the source with tree-sitter and convert into typed AST.
25//! let mut parser = tree_sitter::Parser::new();
26//! parser.set_language(&tree_sitter_lua::LANGUAGE.into()).unwrap();
27//! let tree = parser.parse(src, None).unwrap();
28//! let chunk = Chunk::from_node(tree.root_node(), src).unwrap();
29//!
30//! // The chunk has two top-level children:
31//! // a function statement and a function call statement.
32//! assert_eq!(chunk.children.len(), 2);
33//! assert_eq!(chunk.span.start.row, 0);
34//! assert!(chunk.span.end.row >= 4);
35//! ```
36
37pub use tree_sitter_lua;
38pub use treesitter_types::tree_sitter;
39pub use treesitter_types::{FromNode, LeafNode, ParseError, Span, Spanned};
40
41mod generated;
42pub use generated::*;