all tests green
Signed-off-by: Ava Hahn <ava@aidanis.online>
This commit is contained in:
parent
82854a58f8
commit
93a1e06a53
5 changed files with 94 additions and 32 deletions
20
src/lex.rs
20
src/lex.rs
|
|
@ -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())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue