Implement builtin functions quote and unquote

This commit is contained in:
ConnorSkees 2020-02-08 21:19:54 -05:00
parent 22670a7e4b
commit 86173a3ca7

View File

@ -1,6 +1,7 @@
use std::collections::BTreeMap;
use super::Builtin;
use crate::common::QuoteKind;
use crate::units::Unit;
use crate::value::{Number, Value};
@ -26,4 +27,14 @@ pub(crate) fn register(f: &mut BTreeMap<String, Builtin>) {
_ => todo!("")
}
});
decl!(f "quote", |args, _| {
let s = arg!(args, 0, "string").eval();
match s {
Value::Ident(i, _) => Some(Value::Ident(i, QuoteKind::Double)),
_ => todo!("")
}
});
decl!(f "unquote", |args, _| {
Some(arg!(args, 0, "string").eval().unquote())
});
}