diff --git a/Readme.org b/Readme.org index d605ad3..c6f5a2e 100644 --- a/Readme.org +++ b/Readme.org @@ -301,8 +301,11 @@ 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 append -> cons +*** TODO bool cast *** TODO Quote function *** TODO Eval function +*** TODO lambda *** TODO Lex function *** TODO Input function *** TODO Load (load a script) function @@ -310,8 +313,7 @@ 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 Can enter multiple lines of text, with formatting in repl -*** TODO append -> cons +*** TODO FINISH DOCUMENTATION *** TODO Shell module **** TODO Support for single quoting string literals **** TODO Args parsing helper @@ -320,15 +322,16 @@ Will need a concatenate function for tables **** TODO Foreground process TTY **** TODO Background processes **** TODO Update config env var docstring with functions loaded or unloaded -*** TODO lambda -*** TODO bool cast +**** TODO ESSENTIAL: DOCUMENT POSIX MODULE +*** TODO Can enter multiple lines of text, with formatting in repl +*** TODO Rename to Flesh +*** TODO Create a dedicated community channel on matrix.sunnypup.io +*** TODO Post to relevant channels +*** TODO Custom ast pretty print *** TODO file operations **** TODO read-to-string **** TODO write-to-file -*** TODO Rename to Flesh *** TODO Pick through core/ast and make sure no unnessesary moves are happening -*** TODO Create a dedicated community channel on matrix.sunnypup.io -*** TODO Post to relevant channels *** TODO Network library **** TODO HTTP Client **** TODO TCP Stream client @@ -336,4 +339,3 @@ Will need a concatenate function for tables **** TODO TCP Listener **** TODO HTTP Listener **** TODO UDP Listener -*** TODO Custom ast pretty print diff --git a/src/stl.rs b/src/stl.rs index 0fa5534..b8713a1 100644 --- a/src/stl.rs +++ b/src/stl.rs @@ -31,13 +31,13 @@ pub mod strings; /// any kind of further configuration data into a symtable pub fn static_stdlib(syms: &mut SymTable) -> Result<(), String> { syms.insert( - "append".to_string(), + "cons".to_string(), Symbol { - name: String::from("append"), + name: String::from("cons"), args: Args::Infinite, conditional_branches: false, - docs: append::APPEND_DOCSTRING.to_string(), - value: ValueType::Internal(Rc::new(append::append_callback)), + docs: append::CONS_DOCSTRING.to_string(), + value: ValueType::Internal(Rc::new(append::cons_callback)), }, ); diff --git a/src/stl/append.rs b/src/stl/append.rs index 6dbd9cc..53352b8 100644 --- a/src/stl/append.rs +++ b/src/stl/append.rs @@ -17,10 +17,10 @@ use crate::segment::{Ctr, Seg}; use crate::sym::SymTable; -pub const APPEND_DOCSTRING: &str = "traverses any number of arguments collecting them into a list. +pub const CONS_DOCSTRING: &str = "traverses any number of arguments collecting them into a list. If the first argument is a list, all other arguments are added sequentially to the end of the list contained in the first argument."; -pub fn append_callback(ast: &Seg, _syms: &mut SymTable) -> Result { +pub fn cons_callback(ast: &Seg, _syms: &mut SymTable) -> Result { if let Ctr::Seg(ref s) = *ast.car { let mut temp = s.clone(); if let Ctr::Seg(ref list) = *ast.cdr { diff --git a/tests/test_lib_append.rs b/tests/test_lib_append.rs index 73e297b..7a1ae34 100644 --- a/tests/test_lib_append.rs +++ b/tests/test_lib_append.rs @@ -3,8 +3,8 @@ mod append_lib_tests { use relish::stdlib::{dynamic_stdlib, static_stdlib}; #[test] - fn test_append_to_empty_list() { - let document = "(append () 1)"; + fn test_cons_to_empty_list() { + let document = "(cons () 1)"; let result = "(1)"; let mut syms = SymTable::new(); @@ -19,8 +19,8 @@ mod append_lib_tests { } #[test] - fn test_multi_append_to_empty_list() { - let document = "(append () 1 'two' 3.4)"; + fn test_multi_cons_to_empty_list() { + let document = "(cons () 1 'two' 3.4)"; let result = "(1 'two' 3.4)"; let mut syms = SymTable::new(); @@ -36,8 +36,8 @@ mod append_lib_tests { } #[test] - fn test_append_to_full_list() { - let document = "(append (1 2) 3)"; + fn test_cons_to_full_list() { + let document = "(cons (1 2) 3)"; let result = "(1 2 3)"; let mut syms = SymTable::new(); @@ -53,8 +53,8 @@ mod append_lib_tests { } #[test] - fn test_mono_append() { - let document = "(append)"; + fn test_mono_cons() { + let document = "(cons)"; let result = "()"; let mut syms = SymTable::new(); @@ -70,8 +70,8 @@ mod append_lib_tests { } #[test] - fn test_append_no_list() { - let document = "(append 'test' 1 2 3)"; + fn test_cons_no_list() { + let document = "(cons 'test' 1 2 3)"; let result = "('test' 1 2 3)"; let mut syms = SymTable::new(); diff --git a/tests/test_lib_control.rs b/tests/test_lib_control.rs index 5e852d2..13e2f9b 100644 --- a/tests/test_lib_control.rs +++ b/tests/test_lib_control.rs @@ -34,7 +34,7 @@ mod control_lib_tests { #[test] fn test_complex_case_call() { - let document = "(if true (append () 1) 2)"; + let document = "(if true (cons () 1) 2)"; let result = "(1)"; let mut syms = SymTable::new(); static_stdlib(&mut syms).unwrap(); @@ -51,7 +51,7 @@ mod control_lib_tests { fn test_let_multiphase_locals() { let document = "(let ( (temp '1') - (temp (append () temp '2'))) + (temp (cons () temp '2'))) temp)"; let result = "('1' '2')"; let mut syms = SymTable::new(); @@ -67,7 +67,7 @@ mod control_lib_tests { #[test] fn test_let_multibody_evals() { - let document = "(let ((temp '1')) temp (append () temp '2'))"; + let document = "(let ((temp '1')) temp (cons () temp '2'))"; let result = "('1' '2')"; let mut syms = SymTable::new(); static_stdlib(&mut syms).unwrap(); @@ -84,9 +84,9 @@ mod control_lib_tests { fn test_let_multiphase_local_multibody_evals() { let document = "(let ( (temp '1') - (temp (append () temp '2'))) + (temp (cons () temp '2'))) (echo 'first body') - (append temp '3'))"; + (cons temp '3'))"; let result = "('1' '2' '3')"; let mut syms = SymTable::new();