2024-03-01 03:04:45 +00:00
|
|
|
//! Walks a Conlang AST, interpreting it as a program.
|
|
|
|
#![warn(clippy::all)]
|
2024-02-29 23:51:38 +00:00
|
|
|
#![feature(decl_macro)]
|
2023-10-26 19:48:44 +00:00
|
|
|
|
2024-04-25 00:34:29 +00:00
|
|
|
use cl_ast::Sym;
|
2024-05-19 20:16:22 +00:00
|
|
|
use convalue::ConValue;
|
2024-01-05 23:48:19 +00:00
|
|
|
use env::Environment;
|
2023-10-30 04:47:00 +00:00
|
|
|
use error::{Error, IResult};
|
2024-01-21 11:32:18 +00:00
|
|
|
use interpret::Interpret;
|
2023-10-26 19:48:44 +00:00
|
|
|
|
2023-10-30 04:47:00 +00:00
|
|
|
/// Callable types can be called from within a Conlang program
|
|
|
|
pub trait Callable: std::fmt::Debug {
|
2024-01-06 04:47:16 +00:00
|
|
|
/// Calls this [Callable] in the provided [Environment], with [ConValue] args \
|
2023-10-30 04:47:00 +00:00
|
|
|
/// The Callable is responsible for checking the argument count and validating types
|
2024-01-05 23:48:19 +00:00
|
|
|
fn call(&self, interpreter: &mut Environment, args: &[ConValue]) -> IResult<ConValue>;
|
2023-10-30 04:47:00 +00:00
|
|
|
/// Returns the common name of this identifier.
|
2024-04-25 00:34:29 +00:00
|
|
|
fn name(&self) -> Sym;
|
2023-10-30 04:47:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// [BuiltIn]s are [Callable]s with bespoke definitions
|
2024-02-29 22:48:09 +00:00
|
|
|
pub trait BuiltIn: std::fmt::Debug + Callable {
|
|
|
|
fn description(&self) -> &str;
|
|
|
|
}
|
2023-10-30 04:47:00 +00:00
|
|
|
|
2024-07-28 03:47:46 +00:00
|
|
|
pub mod convalue;
|
2023-10-26 19:48:44 +00:00
|
|
|
|
2024-02-29 23:51:38 +00:00
|
|
|
pub mod interpret;
|
2023-10-30 04:47:00 +00:00
|
|
|
|
2024-07-28 03:47:46 +00:00
|
|
|
pub mod function;
|
2023-10-30 04:47:00 +00:00
|
|
|
|
2024-02-29 22:48:09 +00:00
|
|
|
pub mod builtin;
|
2023-10-30 04:47:00 +00:00
|
|
|
|
2024-07-28 03:47:46 +00:00
|
|
|
pub mod env;
|
2024-01-04 08:18:09 +00:00
|
|
|
|
2024-07-28 03:47:46 +00:00
|
|
|
pub mod error;
|
2024-01-10 05:52:48 +00:00
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
mod tests;
|