tree_sitter_navi_stream/
lib.rs

1//! This crate provides navi_stream language support for the [tree-sitter][] parsing library.
2//!
3//! Typically, you will use the [language][language func] function to add this language to a
4//! tree-sitter [Parser][], and then use the parser to parse some code:
5//!
6//! ```
7//! let code = "";
8//! let mut parser = tree_sitter::Parser::new();
9//! parser.set_language(&tree_sitter_navi_stream::LANGUAGE.into()).expect("Error loading navi_stream grammar");
10//! let tree = parser.parse(code, None).unwrap();
11//! ```
12//!
13//! [Language]: https://docs.rs/tree-sitter/*/tree_sitter/struct.Language.html
14//! [language func]: fn.language.html
15//! [Parser]: https://docs.rs/tree-sitter/*/tree_sitter/struct.Parser.html
16//! [tree-sitter]: https://tree-sitter.github.io/
17use tree_sitter_language::LanguageFn;
18
19extern "C" {
20    fn tree_sitter_navi_stream() -> *const ();
21}
22
23/// Get the tree-sitter [Language][] for this grammar.
24///
25/// [Language]: https://docs.rs/tree-sitter/*/tree_sitter/struct.Language.html
26pub const LANGUAGE: LanguageFn = unsafe { LanguageFn::from_raw(tree_sitter_navi_stream) };
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#static-node-types
31pub const NODE_TYPES: &'static str = include_str!("../../src/node-types.json");
32
33// Uncomment these to include any queries that this grammar contains
34
35pub const HIGHLIGHTS_QUERY: &'static str = include_str!("../../queries/highlights.scm");
36// pub const INJECTIONS_QUERY: &'static str = include_str!("../../queries/injections.scm");
37// pub const LOCALS_QUERY: &'static str = include_str!("../../queries/locals.scm");
38pub const TAGS_QUERY: &'static str = include_str!("../../queries/tags.scm");
39
40#[cfg(test)]
41mod tests {
42    #[test]
43    fn test_can_load_grammar() {
44        let mut parser = tree_sitter::Parser::new();
45        parser
46            .set_language(&super::LANGUAGE.into())
47            .expect("Error loading navi_stream language");
48    }
49}