Most files suffered major changes

- Less ambiguous syntax
- Better parser (Chumsky only does tokenization now)
- Tidy(|ier) error handling
- Facade for simplified embedding
- External code grouped in (fairly) self-contained Systems
- Dynamic action dispatch
- Many STL additions
This commit is contained in:
2023-08-17 20:47:08 +01:00
parent 751a02a1ec
commit 3fdabc29da
139 changed files with 4269 additions and 1783 deletions

26
src/systems/stl/panic.rs Normal file
View File

@@ -0,0 +1,26 @@
use std::fmt::Display;
use crate::foreign::ExternError;
use crate::systems::cast_exprinst::with_str;
use crate::{define_fn, ConstTree, Interner};
/// An unrecoverable error in Orchid land. Because Orchid is lazy, this only
/// invalidates expressions that reference the one that generated it.
pub struct OrchidPanic(String);
impl Display for OrchidPanic {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "Orchid code panicked: {}", self.0)
}
}
impl ExternError for OrchidPanic {}
define_fn! {
/// Takes a message, returns an [ExternError] unconditionally.
Panic = |x| with_str(x, |s| Err(OrchidPanic(s.clone()).into_extern()))
}
pub fn panic(i: &Interner) -> ConstTree {
ConstTree::tree([(i.i("panic"), ConstTree::xfn(Panic))])
}