implementations for quote and eval
This commit is contained in:
parent
61a1b47b85
commit
6daf0867df
2 changed files with 46 additions and 6 deletions
32
Readme.org
32
Readme.org
|
|
@ -301,23 +301,43 @@ This contains any executable target of this project. Notably the main shell file
|
|||
Note: this section will not show the status of each item unless you are viewing it with a proper orgmode viewer.
|
||||
Note: this section only tracks the state of incomplete TODO items. Having everything on here would be cluttered.
|
||||
|
||||
*** TODO Syntax improvements
|
||||
**** WONTDO implicit single quote
|
||||
**** TODO :symbol syntax
|
||||
**** TODO Update Tests
|
||||
**** TODO Update Makefile documentation
|
||||
*** TODO Quote function
|
||||
(just needs tests and stl entries)
|
||||
*** TODO Eval function
|
||||
(just needs tests and stl entries)
|
||||
*** TODO list contains via circuit
|
||||
*** TODO Lambda hack
|
||||
BAD IDEAS
|
||||
- lambda function can use illegal name parameter for symbol names, guaranteeing non collision in symbol table
|
||||
- add some incrementing variable to avoid lambdas colliding with lambdas
|
||||
- custom drop implementation for Ctr that only overrides Symbol, checks for illegal name conventions, and yeets from symtable
|
||||
(how do we get the sym table into the drop impl)
|
||||
- when repl loops, clear lambdas out of the symtable
|
||||
(shit hack and will only work for very simple cases. highly not ideal)
|
||||
GOOD IDEA
|
||||
- could implement a new Ctr type to encapsulate function and args
|
||||
- would need a new case in store for when bound to a var but honestly store should be rewritten
|
||||
- would need a case in eval that mirrors the function call case
|
||||
|
||||
DOCUMENTATION:
|
||||
- let case for creating and applying a lambda
|
||||
*** TODO Map function
|
||||
- DOCUMENTATION + TEST:
|
||||
apply a lambda to a list
|
||||
*** TODO Reduce function
|
||||
*** TODO Input function
|
||||
*** TODO Lex function
|
||||
*** TODO Read function (Input + Lex)
|
||||
*** TODO Caps function (list functions in table)
|
||||
*** TODO Default prompt says "<minimum shell> LAMBDA:"
|
||||
*** TODO Load (load a script) function
|
||||
Pull/Refactor the logic out of the configure functions.
|
||||
Optionally return a list of new variables and/or functions?
|
||||
Will need a concatenate function for tables
|
||||
*** TODO Main shell calls Load function on arg and exits
|
||||
*** TODO Ship a relish-based stdlib
|
||||
*** TODO FINISH DOCUMENTATION
|
||||
*** TODO Shell module
|
||||
*** TODO Shell module-
|
||||
**** TODO only loadable via POSIX config var
|
||||
Overload Load function to call a binary too
|
||||
**** TODO arg processor because these are control flow
|
||||
|
|
|
|||
|
|
@ -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