2024-01-25 12:10:45 +00:00
|
|
|
//! The Dust library is used to parse, format and run dust source code.
|
2023-08-28 13:51:04 +00:00
|
|
|
//!
|
2024-01-25 12:10:45 +00:00
|
|
|
//! See the [interpret] module for more information.
|
2024-01-30 23:13:30 +00:00
|
|
|
//!
|
|
|
|
//! You can use this library externally by calling either of the "interpret"
|
|
|
|
//! functions or by constructing your own Interpreter.
|
2023-08-22 15:40:50 +00:00
|
|
|
pub use crate::{
|
2024-02-11 01:50:49 +00:00
|
|
|
abstract_tree::*,
|
|
|
|
built_in_functions::BuiltInFunction,
|
|
|
|
context::{Context, ValueData},
|
|
|
|
error::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;
|
|
|
|
|
2024-01-30 23:13:30 +00:00
|
|
|
pub mod abstract_tree;
|
2023-11-28 22:54:17 +00:00
|
|
|
pub mod built_in_functions;
|
2024-02-15 06:51:05 +00:00
|
|
|
pub mod built_in_type_definitions;
|
2024-02-15 15:33:25 +00:00
|
|
|
pub mod built_in_types;
|
2024-02-15 07:02:48 +00:00
|
|
|
pub mod built_in_values;
|
2024-02-10 23:29:11 +00:00
|
|
|
pub mod context;
|
2024-01-30 23:13:30 +00:00
|
|
|
pub mod error;
|
|
|
|
pub mod interpret;
|
|
|
|
pub 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() }
|
|
|
|
}
|
|
|
|
|
|
|
|
#[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");
|
|
|
|
}
|
|
|
|
}
|