Added macro and internal fn types
This commit is contained in:
parent
a825b082cf
commit
6c71bde8a8
|
@ -66,7 +66,7 @@ fn stream_of_lexer<'a>(
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
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)
|
assert_eq!(read(src).unwrap(), expected)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ use ordered_float::OrderedFloat;
|
||||||
use std::{
|
use std::{
|
||||||
borrow::Cow,
|
borrow::Cow,
|
||||||
collections::BTreeMap,
|
collections::BTreeMap,
|
||||||
fmt::{Display, Write},
|
fmt::{Debug, Display, Write},
|
||||||
rc::Rc,
|
rc::Rc,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -15,6 +15,8 @@ pub enum Value<'a> {
|
||||||
Map(BTreeMap<Self, Self>),
|
Map(BTreeMap<Self, Self>),
|
||||||
Module(Module<'a>),
|
Module(Module<'a>),
|
||||||
Function(Function<'a>),
|
Function(Function<'a>),
|
||||||
|
InternalFn(fn(&'a List<'a>) -> Value<'a>),
|
||||||
|
Macro(/* TODO: Bytecode */),
|
||||||
Symbol(Symbol<'a>),
|
Symbol(Symbol<'a>),
|
||||||
Keyword(Cow<'a, str>),
|
Keyword(Cow<'a, str>),
|
||||||
Bool(bool),
|
Bool(bool),
|
||||||
|
@ -83,7 +85,9 @@ impl<'a> Display for Value<'a> {
|
||||||
Value::Module(_) => write!(f, "#module#"),
|
Value::Module(_) => write!(f, "#module#"),
|
||||||
Value::Symbol(sym) => write!(f, "{sym}"),
|
Value::Symbol(sym) => write!(f, "{sym}"),
|
||||||
Value::Keyword(kw) => write!(f, ":{kw}"),
|
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::Bool(b) => write!(f, "{b}"),
|
||||||
Value::Number(n) => write!(f, "{n}"),
|
Value::Number(n) => write!(f, "{n}"),
|
||||||
Value::String(s) => write!(f, "\"{s}\""),
|
Value::String(s) => write!(f, "\"{s}\""),
|
||||||
|
|
Loading…
Reference in a new issue