October commit

- custom parser support and infra
- type-tagging and traits (untested)
- match expressions
This commit is contained in:
2023-10-24 22:17:37 +01:00
parent c961506a3a
commit f77e4fd90a
73 changed files with 1904 additions and 558 deletions

View File

@@ -1,22 +1,22 @@
use std::fmt::Display;
use std::rc::Rc;
use std::fmt::{Debug, Display};
use std::sync::Arc;
use crate::foreign::ExternError;
use crate::{Location, Sym};
/// Problems in the process of execution
#[derive(Clone, Debug)]
#[derive(Debug, Clone)]
pub enum RuntimeError {
/// A Rust function encountered an error
Extern(Rc<dyn ExternError>),
Extern(Arc<dyn ExternError>),
/// Primitive applied as function
NonFunctionApplication(Location),
/// Symbol not in context
MissingSymbol(Sym, Location),
}
impl From<Rc<dyn ExternError>> for RuntimeError {
fn from(value: Rc<dyn ExternError>) -> Self { Self::Extern(value) }
impl From<Arc<dyn ExternError>> for RuntimeError {
fn from(value: Arc<dyn ExternError>) -> Self { Self::Extern(value) }
}
impl Display for RuntimeError {

View File

@@ -1,5 +1,5 @@
use std::any::{Any, TypeId};
use std::rc::Rc;
use std::sync::Arc;
use hashbrown::HashMap;
use trait_set::trait_set;
@@ -58,7 +58,7 @@ impl<'a> HandlerTable<'a> {
/// Various possible outcomes of a [Handler] execution. Ok returns control to
/// the interpreter. The meaning of Err is decided by the value in it.
pub type HandlerRes = Result<ExprInst, Rc<dyn ExternError>>;
pub type HandlerRes = Result<ExprInst, Arc<dyn ExternError>>;
/// [run] orchid code, executing any commands it returns using the specified
/// [Handler]s.