all tests green

Signed-off-by: Ava Hahn <ava@aidanis.online>
This commit is contained in:
Ava Hahn 2023-02-25 23:36:30 -08:00
parent 82854a58f8
commit 93a1e06a53
Signed by untrusted user who does not match committer: affine
GPG key ID: 3A4645B8CF806069
5 changed files with 94 additions and 32 deletions

View file

@ -201,7 +201,25 @@ fn process(document: &String) -> Result<Box<Seg>, String> {
if is_str {
Err(UNMATCHED_STR_DELIM.to_string())
} else {
Err(UNMATCHED_LIST_DELIM.to_string())
if ref_stack.is_empty() {
let obj;
if token == "true" {
obj = Box::from(Ctr::Bool(true));
} else if token == "false" {
obj = Box::from(Ctr::Bool(false));
} else if let Ok(i) = token.parse::<i128>() {
obj = Box::from(Ctr::Integer(i));
} else if let Ok(f) = token.parse::<f64>() {
obj = Box::from(Ctr::Float(f));
} else if let Some(s) = tok_is_symbol(&token) {
obj = Box::from(Ctr::Symbol(s));
} else {
return Err(format!("Unparsable token: {}", token));
}
Ok(Box::new(Seg::from_mono(obj)))
} else {
Err(UNMATCHED_LIST_DELIM.to_string())
}
}
}