diff options
author | Dominick Allen <dominick.allen1989@gmail.com> | 2020-06-28 19:50:35 -0500 |
---|---|---|
committer | Dominick Allen <dominick.allen1989@gmail.com> | 2020-06-28 19:50:35 -0500 |
commit | 2ffb5357e0e35d415311a40eea14e9cc99dd54ab (patch) | |
tree | 0410800cd74956d294a76ef6e47d527b0c1adeed /src/lib/tokenize.rs | |
parent | 3eb53c36123c4a8a8f336c255a9d5a7b44ca922c (diff) |
Improve read functionality.
Diffstat (limited to 'src/lib/tokenize.rs')
-rw-r--r-- | src/lib/tokenize.rs | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/lib/tokenize.rs b/src/lib/tokenize.rs index 0a50036..483536f 100644 --- a/src/lib/tokenize.rs +++ b/src/lib/tokenize.rs @@ -1,4 +1,5 @@ use super::types::Type; +use super::types::FloatType; use super::types::Number; use super::types::Op; use super::sexpr::SExpr; @@ -242,7 +243,7 @@ pub fn is_int(word: &str) -> MaybeToken { } pub fn is_float(word: &str) -> MaybeToken { - match word.parse::<f32>() { + match word.parse::<FloatType>() { Ok(x) => (Some(Ok(Token::Value(Type::Number(Number::Float(x))))), word.len()), _ => (None, 0) } @@ -268,7 +269,7 @@ pub fn descend(tokenstream: &mut TokenStream) -> Result<SExpr, String> { let token = match tokenstream.next() { Some(Ok(x)) => x, Some(Err(f)) => return Err(f), - None => panic!("Empty string".to_string()) + None => return Err("Unexpected end of expression".to_string()) }; match token { |