fix: quote macro
This commit is contained in:
parent
6c08af02a1
commit
5e98637ae0
3 changed files with 8 additions and 0 deletions
6
mute-interpreter/src/env/standard.rs
vendored
6
mute-interpreter/src/env/standard.rs
vendored
|
@ -19,6 +19,12 @@ pub(super) fn standard() -> HashMap<String, Value> {
|
||||||
(macro* (name args body) ~(define (,name (fn* ,args ,body))) )
|
(macro* (name args body) ~(define (,name (fn* ,args ,body))) )
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
(
|
||||||
|
"quote",
|
||||||
|
inline! {
|
||||||
|
(macro* (var) ~^,var)
|
||||||
|
},
|
||||||
|
),
|
||||||
]
|
]
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|(k, v)| (k.to_string(), Value::Node(v)))
|
.map(|(k, v)| (k.to_string(), Value::Node(v)))
|
||||||
|
|
|
@ -211,6 +211,7 @@ pub fn eval_node(env: &Environment, ast_node: Node) -> Result<Node> {
|
||||||
Node::Eval(list) => unquote!(Do, list),
|
Node::Eval(list) => unquote!(Do, list),
|
||||||
Node::Apply(list) => unquote!(Apply, list),
|
Node::Apply(list) => unquote!(Apply, list),
|
||||||
|
|
||||||
|
Node::Quote(node) => Ok(Node::Quote(Box::new(unquote(env, *node)?))),
|
||||||
Node::Unquote(_) => eval_node(env, node),
|
Node::Unquote(_) => eval_node(env, node),
|
||||||
node => Ok(node),
|
node => Ok(node),
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,6 +92,7 @@ fn next_token(input: &mut Peekable<Chars>) -> Result<Option<Token>, Error> {
|
||||||
'{' => Token::LeftBrace,
|
'{' => Token::LeftBrace,
|
||||||
'}' => Token::RightBrace,
|
'}' => Token::RightBrace,
|
||||||
|
|
||||||
|
'^' => Token::Quote,
|
||||||
'\'' => Token::Quote,
|
'\'' => Token::Quote,
|
||||||
'`' => Token::Quasiquote,
|
'`' => Token::Quasiquote,
|
||||||
'~' => Token::Quasiquote,
|
'~' => Token::Quasiquote,
|
||||||
|
|
Loading…
Reference in a new issue