various stuff
This commit is contained in:
parent
cb20383f08
commit
1c4b04dc6d
|
@ -1,2 +1,8 @@
|
|||
use super::Str;
|
||||
use crate::syntax::ast::{Expr, Spanned};
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct Function;
|
||||
pub struct Function<'s> {
|
||||
params: Box<[Str<'s>]>,
|
||||
ast: Box<[Spanned<Expr<'s>>]>,
|
||||
}
|
||||
|
|
|
@ -23,8 +23,9 @@ pub enum Value<'s> {
|
|||
Keyword(Str<'s>),
|
||||
Number(OrderedF64),
|
||||
String(Str<'s>),
|
||||
Function(Function),
|
||||
Macro(Function),
|
||||
Function(Function<'s>),
|
||||
NativeFun(fn(&'s [Value<'s>]) -> Value<'s>),
|
||||
Macro(Function<'s>),
|
||||
}
|
||||
|
||||
impl<'s> From<Spanned<Expr<'s>>> for Value<'s> {
|
||||
|
@ -65,6 +66,7 @@ impl<'s> Display for Value<'s> {
|
|||
Value::Number(n) => n.fmt(f),
|
||||
Value::String(s) => write!(f, "\"{s}\""),
|
||||
Value::Function(_) => "#fun#".fmt(f),
|
||||
Value::NativeFun(fp) => write!(f, "#native-fun({fp:p})#"),
|
||||
Value::Macro(_) => "#macro#".fmt(f),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,6 +31,8 @@ impl<T: PartialEq> PartialEq for Spanned<T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T: Eq> Eq for Spanned<T> {}
|
||||
|
||||
impl<T: Hash> Hash for Spanned<T> {
|
||||
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
|
||||
self.item.hash(state);
|
||||
|
@ -38,7 +40,7 @@ impl<T: Hash> Hash for Spanned<T> {
|
|||
}
|
||||
|
||||
/// A Wisp AST
|
||||
#[derive(Debug, Clone, Hash, PartialEq)]
|
||||
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
|
||||
pub enum Expr<'s> {
|
||||
List(Vec<Spanned<Self>>),
|
||||
Vector(Vec<Spanned<Self>>),
|
||||
|
|
Loading…
Reference in a new issue