implementations for quote and eval
This commit is contained in:
parent
61a1b47b85
commit
6daf0867df
2 changed files with 46 additions and 6 deletions
|
|
@ -20,6 +20,26 @@ use crate::segment::{Ctr, Seg};
|
|||
use crate::sym::{Args, SymTable, Symbol, UserFn, ValueType};
|
||||
use std::env;
|
||||
|
||||
pub const QUOTE_DOCSTRING: &str = "takes a single unevaluated tree and returns it as it is: unevaluated.";
|
||||
|
||||
pub fn quote_callback(ast: &Seg, _syms: &mut SymTable) -> Result<Ctr, String> {
|
||||
if ast.len() > 1 {
|
||||
Err("do not quote more than one thing at a time".to_string())
|
||||
} else {
|
||||
Ok(Ctr::Seg(ast.clone()))
|
||||
}
|
||||
}
|
||||
|
||||
pub const EVAL_DOCSTRING: &str = "takes an unevaluated argument and evaluates it.";
|
||||
|
||||
pub fn eval_callback(ast: &Seg, syms: &mut SymTable) -> Result<Ctr, String> {
|
||||
if ast.len() > 1 {
|
||||
Err("do not quote more than one thing at a time".to_string())
|
||||
} else {
|
||||
Ok(*eval(ast, syms)?.clone())
|
||||
}
|
||||
}
|
||||
|
||||
pub const HELP_DOCSTRING: &str = "prints help text for a given symbol. Expects only one argument.";
|
||||
|
||||
pub fn help_callback(ast: &Seg, syms: &mut SymTable) -> Result<Ctr, String> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue