Added macro and internal fn types

main
ondra05 2022-07-21 22:50:58 +02:00
parent 889a444809
commit 0d36a8ee4d
2 changed files with 7 additions and 3 deletions

View File

@ -66,7 +66,7 @@ fn stream_of_lexer<'a>(
mod tests {
use super::*;
fn assert_parse(src: &str, expected: &[Value]) {
fn assert_parse<'a>(src: &'a str, expected: &'a [Value<'a>]) {
assert_eq!(read(src).unwrap(), expected)
}

View File

@ -3,7 +3,7 @@ use ordered_float::OrderedFloat;
use std::{
borrow::Cow,
collections::BTreeMap,
fmt::{Display, Write},
fmt::{Debug, Display, Write},
rc::Rc,
};
@ -15,6 +15,8 @@ pub enum Value<'a> {
Map(BTreeMap<Self, Self>),
Module(Module<'a>),
Function(Function<'a>),
InternalFn(fn(&'a List<'a>) -> Value<'a>),
Macro(/* TODO: Bytecode */),
Symbol(Symbol<'a>),
Keyword(Cow<'a, str>),
Bool(bool),
@ -83,7 +85,9 @@ impl<'a> Display for Value<'a> {
Value::Module(_) => write!(f, "#module#"),
Value::Symbol(sym) => write!(f, "{sym}"),
Value::Keyword(kw) => write!(f, ":{kw}"),
Value::Function { .. } => write!(f, "fn"),
Value::Function { .. } => write!(f, "#fn#"),
Value::InternalFn(function) => write!(f, "#internal-fn@{function:p}"),
Value::Macro() => write!(f, "#macro#"),
Value::Bool(b) => write!(f, "{b}"),
Value::Number(n) => write!(f, "{n}"),
Value::String(s) => write!(f, "\"{s}\""),