repl now complete
Signed-off-by: Ava Hahn <ava@aidanis.online>
This commit is contained in:
parent
fbb85f2e3d
commit
2439a37aaa
9 changed files with 188 additions and 123 deletions
34
src/lex.rs
34
src/lex.rs
|
|
@ -200,26 +200,24 @@ fn process(document: &String) -> Result<Box<Seg>, String> {
|
|||
|
||||
if is_str {
|
||||
Err(UNMATCHED_STR_DELIM.to_string())
|
||||
} else {
|
||||
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 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 {
|
||||
Err(UNMATCHED_LIST_DELIM.to_string())
|
||||
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