Skip to main content

treesitter_types_elixir/
lib.rs

1//! Strongly-typed AST types for Elixir, auto-generated from
2//! [`tree-sitter-elixir`](https://docs.rs/tree-sitter-elixir)'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_elixir::*;
14//!
15//! // A minimal Elixir hello-world program.
16//! let src = b"\
17//! defmodule Hello do
18//!   def world do
19//!     IO.puts(\"Hello, World!\")
20//!   end
21//! end
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_elixir::LANGUAGE.into()).unwrap();
27//! let tree = parser.parse(src, None).unwrap();
28//! let source = Source::from_node(tree.root_node(), src).unwrap();
29//!
30//! // The source has one top-level child: the `defmodule` call.
31//! assert_eq!(source.children.len(), 1);
32//! assert_eq!(source.span.start.row, 0);
33//! assert!(source.span.end.row >= 4);
34//! ```
35
36pub use tree_sitter_elixir;
37pub use treesitter_types::tree_sitter;
38pub use treesitter_types::{FromNode, LeafNode, ParseError, Span, Spanned};
39
40mod generated;
41pub use generated::*;