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::{
|
2023-10-06 17:32:58 +00:00
|
|
|
abstract_tree::*,
|
2023-08-22 15:40:50 +00:00
|
|
|
error::*,
|
2023-10-06 17:32:58 +00:00
|
|
|
evaluator::*,
|
2023-10-26 22:03:59 +00:00
|
|
|
value::{function::Function, list::List, map::Map, table::Table, value_type::ValueType, Value},
|
2023-08-22 15:40:50 +00:00
|
|
|
};
|
|
|
|
|
2023-10-06 17:32:58 +00:00
|
|
|
mod abstract_tree;
|
2023-08-22 15:40:50 +00:00
|
|
|
mod error;
|
2023-10-06 17:32:58 +00:00
|
|
|
mod evaluator;
|
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-18 22:26:45 +00:00
|
|
|
pub const NODE_TYPES: &'static 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");
|
|
|
|
}
|
|
|
|
}
|