diff --git a/Readme.org b/Readme.org index a0479f2..f691b5c 100644 --- a/Readme.org +++ b/Readme.org @@ -301,11 +301,16 @@ 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 *** TODO Eval function -*** TODO lambda -*** TODO Lex function *** TODO Input function +*** TODO Lex function +*** TODO Read function (Input + Lex) *** 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? @@ -313,13 +318,14 @@ Will need a concatenate function for tables *** TODO Main shell calls Load function on arg and exits *** TODO FINISH DOCUMENTATION *** TODO Shell module -**** TODO Support for single quoting string literals -**** TODO Args parsing helper +**** TODO only loadable via POSIX config var +Overload Load function to call a binary too +**** TODO arg processor because these are control flow **** TODO Process launching with environment variables **** TODO Optional form of process which allows fd redirecting -**** TODO Foreground process TTY -**** TODO Background processes -**** TODO Update config env var docstring with functions loaded or unloaded +**** TODO Background processes (bg function) +**** TODO Foreground process TTY (fg function) +**** TODO list jobs (j function) **** TODO ESSENTIAL: DOCUMENT POSIX MODULE *** TODO Can enter multiple lines of text, with formatting in repl *** TODO Rename to Flesh diff --git a/src/lex.rs b/src/lex.rs index b695151..8944316 100644 --- a/src/lex.rs +++ b/src/lex.rs @@ -131,7 +131,7 @@ fn process(document: &String) -> Result, String> { delim_stack.push(c); } // eat the whole line - '#' => { + '#' | ';' => { ign = true; delim_stack.push('\n'); } diff --git a/tests/test_lex.rs b/tests/test_lex.rs index 5b01bae..409f9ce 100644 --- a/tests/test_lex.rs +++ b/tests/test_lex.rs @@ -14,16 +14,16 @@ mod lex_tests { } #[test] - fn test_lex_complex_list() { - let document = String::from("(hello 'world' (1 2 (1 2 3)) 1 2 3)"); - assert_eq!(lex(&document).unwrap().to_string(), document); + fn test_bad_symbol() { + let document = String::from("(as/dd)"); + let output: &str = "Problem lexing document: \"Unparsable token: as/dd\""; + assert_eq!(lex(&document).err().unwrap(), output.to_string(),); } #[test] - fn test_bad_symbol() { - let document = String::from("(as;dd)"); - let output: &str = "Problem lexing document: \"Unparsable token: as;dd\""; - assert_eq!(lex(&document).err().unwrap(), output.to_string(),); + fn test_lex_complex_list() { + let document = String::from("(hello 'world' (1 2 (1 2 3)) 1 2 3)"); + assert_eq!(lex(&document).unwrap().to_string(), document); } #[test] @@ -53,23 +53,45 @@ mod lex_tests { } #[test] - fn test_comment() { + fn test_comment_1() { let document = String::from("#!/bin/relish\n(one two)"); let output: &str = "(one two)"; assert_eq!(lex(&document).unwrap().to_string(), output.to_string(),); } #[test] - fn test_postline_comment() { + fn test_comment_2() { + let document = String::from(";; big doc string\n(one two)"); + let output: &str = "(one two)"; + assert_eq!(lex(&document).unwrap().to_string(), output.to_string(),); + } + + #[test] + fn test_postline_comment_1() { let document = - String::from("#!/bin/relish\n((one two)# another doc comment\n(three four))"); + String::from("#!/bin/relish\n((one two)# another doc comment\n('three' four))"); + let output: &str = "((one two) ('three' four))"; + assert_eq!(lex(&document).unwrap().to_string(), output.to_string(),); + } + + #[test] + fn test_postline_comment_2() { + let document = + String::from("#!/bin/relish\n((one two);;another doc comment\n(three four))"); let output: &str = "((one two) (three four))"; assert_eq!(lex(&document).unwrap().to_string(), output.to_string(),); } #[test] - fn test_inline_comment() { - let document = String::from("#!/bin/relish\n((one two)\n# another doc comment\nthree)"); + fn test_inline_comment_1() { + let document = String::from("#!/bin/relish\n((one two)\n# another comment\nthree)"); + let output: &str = "((one two) three)"; + assert_eq!(lex(&document).unwrap().to_string(), output.to_string(),); + } + + #[test] + fn test_inline_comment_2() { + let document = String::from("# head\n((one two)\n;; another comment\nthree)"); let output: &str = "((one two) three)"; assert_eq!(lex(&document).unwrap().to_string(), output.to_string(),); }