Skip to main content

tree_sitter_actions/
lib.rs

1//! Tree-sitter parser for the `.actions` file format.
2//!
3//! # Parsing
4//!
5//! Use the [LANGUAGE] constant to parse `.actions` files:
6//!
7//! ```
8//! let code = "[ ] Buy milk\n!1\n";
9//! let mut parser = tree_sitter::Parser::new();
10//! parser
11//!     .set_language(&tree_sitter_actions::LANGUAGE.into())
12//!     .expect("Error loading Actions parser");
13//! let tree = parser.parse(code, None).unwrap();
14//! assert!(!tree.root_node().has_error());
15//! ```
16//!
17use tree_sitter_language::LanguageFn;
18
19extern "C" {
20    fn tree_sitter_actions() -> *const ();
21}
22
23/// The tree-sitter [`LanguageFn`][LanguageFn] for this grammar.
24///
25/// [LanguageFn]: https://docs.rs/tree-sitter-language/*/tree_sitter_language/struct.LanguageFn.html
26pub const LANGUAGE: LanguageFn = unsafe { LanguageFn::from_raw(tree_sitter_actions) };
27
28/// The content of the [`node-types.json`][] file for this grammar.
29///
30/// [`node-types.json`]: https://tree-sitter.github.io/tree-sitter/using-parsers/6-static-node-types
31pub const NODE_TYPES: &str = include_str!("../../src/node-types.json");
32
33/// The syntax highlighting query for this grammar.
34pub const HIGHLIGHTS_QUERY: &str = include_str!("../../queries/actions/highlights.scm");
35
36/// The indentation query for this grammar.
37pub const INDENTS_QUERY: &str = include_str!("../../queries/actions/indents.scm");
38
39/// The formatting query for this grammar.
40pub const FORMATTING_QUERY: &str = include_str!("../../queries/actions/formatting.scm");