a few changes enclosed:

* documented deps
* mild string escaping
* corrected a misbehavior in sym
This commit is contained in:
Ava Apples Affine 2023-04-19 21:03:26 -07:00
parent d7864ee628
commit 5afc2cc4a1
Signed by: affine
GPG key ID: 3A4645B8CF806069
4 changed files with 22 additions and 14 deletions

View file

@ -1,12 +1,18 @@
[package] [package]
name = "relish" name = "relish"
version = "0.1.0" version = "0.2.0"
authors = ["Ava <ava@sunnypup.io>"] authors = ["Ava <ava@sunnypup.io>"]
edition = "2018" edition = "2021"
[dependencies] [dependencies]
# used in config (src/run.rs)
dirs = "3.0" dirs = "3.0"
# these two are used in src/bin/relish.rs to manage a prompt
nu-ansi-term = "0.47.0" nu-ansi-term = "0.47.0"
reedline = "0.17.0" reedline = "0.17.0"
# these two used in posix shell layer (src/stl/posix.rs)
nix = "0.26.2" nix = "0.26.2"
ctrlc = { version = "3.0", features = ["termination"] } ctrlc = { version = "3.0", features = ["termination"] }
# this one provides a global constant lookup table for simple
# string escaping in the lexer
phf = { version = "0.11", default-features = false, features = ["macros"] }

View file

@ -489,7 +489,6 @@ Note: this section only tracks the state of incomplete TODO items. Having everyt
- be able to fg a bg process - be able to fg a bg process
- be able to bg and fg process (ctrl z?) - be able to bg and fg process (ctrl z?)
- Documentation! - Documentation!
- Escape sequences in strings
- logging library - logging library
- make const all the error messages - make const all the error messages
- make presentation on relish - make presentation on relish

View file

@ -16,10 +16,18 @@
*/ */
use crate::segment::{Ctr, Seg}; use crate::segment::{Ctr, Seg};
use phf::{Map, phf_map};
const UNMATCHED_STR_DELIM: &str = "Unmatched string delimiter in input"; const UNMATCHED_STR_DELIM: &str = "Unmatched string delimiter in input";
const UNMATCHED_LIST_DELIM: &str = "Unmatched list delimiter in input"; const UNMATCHED_LIST_DELIM: &str = "Unmatched list delimiter in input";
static ESCAPES: Map<char, char> = phf_map! {
'n' => '\n',
't' => '\t',
'\\' => '\\',
};
/* takes a line of user input /* takes a line of user input
* returns an unsimplified tree of tokens. * returns an unsimplified tree of tokens.
*/ */
@ -71,7 +79,7 @@ fn process(document: &String) -> Result<Box<Seg>, String> {
delim = *d; delim = *d;
if delim == '*' { if delim == '*' {
token.push(c); token.push(ESCAPES[&c]);
delim_stack.pop(); delim_stack.pop();
continue; continue;
@ -136,7 +144,7 @@ fn process(document: &String) -> Result<Box<Seg>, String> {
delim_stack.push('\n'); delim_stack.push('\n');
} }
// escape next char // escape next char
'\\' => { '\\' => if is_str {
delim_stack.push('*'); delim_stack.push('*');
} }
// add to token // add to token

View file

@ -132,9 +132,6 @@ impl SymTable {
// but we dont want to increment it // but we dont want to increment it
symbol.__generation -= 1; symbol.__generation -= 1;
self.insert(name.to_string(), symbol.clone()); self.insert(name.to_string(), symbol.clone());
let cond_args: &Seg;
let outer_scope_seg_holder: Seg;
if let ValueType::VarForm(ref val) = symbol.value { if let ValueType::VarForm(ref val) = symbol.value {
match **val { match **val {
Ctr::Lambda(ref l) if call_func => { Ctr::Lambda(ref l) if call_func => {
@ -147,13 +144,11 @@ impl SymTable {
_ => return Ok(val.clone()), _ => return Ok(val.clone()),
} }
} else if call_func { } else if call_func {
cond_args = args symbol.call(args, self)
} else { } else {
outer_scope_seg_holder = Seg::new(); // its a function but call_func is off
cond_args = &outer_scope_seg_holder; Ok(Box::new(Ctr::Symbol(name.to_string())))
} }
symbol.call(cond_args, self)
} }
pub fn is_function_type(&self, name: &String) -> Option<bool> { pub fn is_function_type(&self, name: &String) -> Option<bool> {