one less library

Signed-off-by: Ava Affine <ava@sunnypup.io>
This commit is contained in:
Ava Apples Affine 2024-07-29 10:42:09 -07:00
parent d79e87dbd2
commit 7800b483da
2 changed files with 11 additions and 14 deletions

View file

@ -5,10 +5,8 @@ authors = ["Ava <ava@sunnypup.io>"]
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"

View file

@ -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<char, char> = phf_map! {
#[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<Box<Seg>, String> {
delim = *d;
if delim == '*' {
token.push(ESCAPES.get(&c)
.cloned()
.or(Some(c))
.unwrap());
token.push(escape(&c));
delim_stack.pop();
continue;