diff --git a/core/Cargo.toml b/core/Cargo.toml index 8e55239..6cd542c 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -5,10 +5,8 @@ authors = ["Ava "] edition = "2021" [dependencies] +# cant have math without libc I guess... libm = "0.2.8" -# this one provides a global constant lookup table for simple -# string escaping in the lexer -phf = { version = "0.11", default-features = false, features = ["macros"] } [lib] name = "flesh" diff --git a/core/src/lex.rs b/core/src/lex.rs index bac40f8..c8a006b 100644 --- a/core/src/lex.rs +++ b/core/src/lex.rs @@ -19,17 +19,19 @@ use alloc::boxed::Box; use alloc::string::{String, ToString}; use crate::segment::{Ctr, Seg}; use crate::error::{Traceback, start_trace}; -use phf::{Map, phf_map}; const UNMATCHED_STR_DELIM: &str = "Unmatched string delimiter in input"; const UNMATCHED_LIST_DELIM: &str = "Unmatched list delimiter in input"; - -static ESCAPES: Map = phf_map! { - 'n' => '\n', - 't' => '\t', - '\\' => '\\', -}; +#[inline] +fn escape(input: &char) -> char { + match input { + 'n' => '\n', + 't' => '\t', + '\\' => '\\', + _ => input.clone(), + } +} /* takes a line of user input * returns an unsimplified tree of tokens. @@ -86,10 +88,7 @@ fn process(document: &String) -> Result, String> { delim = *d; if delim == '*' { - token.push(ESCAPES.get(&c) - .cloned() - .or(Some(c)) - .unwrap()); + token.push(escape(&c)); delim_stack.pop(); continue;