1 //! This crate provides api_notation language support for the [tree-sitter][] parsing library.
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:
8 //! let mut parser = tree_sitter::Parser::new();
9 //! parser.set_language(tree_sitter_api_notation::language()).expect("Error loading api_notation grammar");
10 //! let tree = parser.parse(code, None).unwrap();
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/
18 use tree_sitter::Language;
21 fn tree_sitter_api_notation() -> Language;
24 /// Get the tree-sitter [Language][] for this grammar.
26 /// [Language]: https://docs.rs/tree-sitter/*/tree_sitter/struct.Language.html
27 pub fn language() -> Language {
28 unsafe { tree_sitter_api_notation() }
31 /// The content of the [`node-types.json`][] file for this grammar.
33 /// [`node-types.json`]: https://tree-sitter.github.io/tree-sitter/using-parsers#static-node-types
34 pub const NODE_TYPES: &'static str = include_str!("../../src/node-types.json");
36 // Uncomment these to include any queries that this grammar contains
38 // pub const HIGHLIGHTS_QUERY: &'static str = include_str!("../../queries/highlights.scm");
39 // pub const INJECTIONS_QUERY: &'static str = include_str!("../../queries/injections.scm");
40 // pub const LOCALS_QUERY: &'static str = include_str!("../../queries/locals.scm");
41 // pub const TAGS_QUERY: &'static str = include_str!("../../queries/tags.scm");
46 fn test_can_load_grammar() {
47 let mut parser = tree_sitter::Parser::new();
49 .set_language(super::language())
50 .expect("Error loading api_notation language");