2023-08-28 13:51:04 +00:00
|
|
|
//! The Dust library is used to implement the Dust language, `src/main.rs` implements the command
|
|
|
|
//! line binary.
|
|
|
|
//!
|
|
|
|
//! Using this library is simple and straightforward, see the [inferface] module for instructions on
|
|
|
|
//! interpreting Dust code. Most of the language's features are implemented in the [tools] module.
|
2023-08-22 15:40:50 +00:00
|
|
|
pub use crate::{
|
2024-01-23 22:35:12 +00:00
|
|
|
abstract_tree::*, built_in_functions::BuiltInFunction, error::*, interpret::*, value::*,
|
2023-08-22 15:40:50 +00:00
|
|
|
};
|
|
|
|
|
2024-01-06 03:26:37 +00:00
|
|
|
pub use tree_sitter::Node as SyntaxNode;
|
|
|
|
|
2023-10-06 17:32:58 +00:00
|
|
|
mod abstract_tree;
|
2023-11-28 22:54:17 +00:00
|
|
|
pub mod built_in_functions;
|
2023-08-22 15:40:50 +00:00
|
|
|
mod error;
|
2023-12-29 19:01:54 +00:00
|
|
|
mod interpret;
|
2023-08-22 15:40:50 +00:00
|
|
|
mod value;
|
2023-09-28 19:58:01 +00:00
|
|
|
|
|
|
|
use tree_sitter::Language;
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
fn tree_sitter_dust() -> Language;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Get the tree-sitter [Language][] for this grammar.
|
|
|
|
///
|
|
|
|
/// [Language]: https://docs.rs/tree-sitter/*/tree_sitter/struct.Language.html
|
|
|
|
pub fn language() -> Language {
|
|
|
|
unsafe { tree_sitter_dust() }
|
|
|
|
}
|
|
|
|
|
|
|
|
/// The content of the [`node-types.json`][] file for this grammar.
|
|
|
|
///
|
|
|
|
/// [`node-types.json`]: https://tree-sitter.github.io/tree-sitter/using-parsers#static-node-types
|
2023-10-30 19:48:43 +00:00
|
|
|
pub const NODE_TYPES: &str = include_str!("../tree-sitter-dust/src/node-types.json");
|
2023-09-28 19:58:01 +00:00
|
|
|
|
|
|
|
// Uncomment these to include any queries that this grammar contains
|
|
|
|
|
|
|
|
// pub const HIGHLIGHTS_QUERY: &'static str = include_str!("../../queries/highlights.scm");
|
|
|
|
// pub const INJECTIONS_QUERY: &'static str = include_str!("../../queries/injections.scm");
|
|
|
|
// pub const LOCALS_QUERY: &'static str = include_str!("../../queries/locals.scm");
|
|
|
|
// pub const TAGS_QUERY: &'static str = include_str!("../../queries/tags.scm");
|
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
mod tests {
|
|
|
|
#[test]
|
|
|
|
fn test_can_load_grammar() {
|
|
|
|
let mut parser = tree_sitter::Parser::new();
|
|
|
|
parser
|
|
|
|
.set_language(super::language())
|
|
|
|
.expect("Error loading dust language");
|
|
|
|
}
|
|
|
|
}
|