aboutsummaryrefslogtreecommitdiff
path: root/compiler/src/ast/parser.rs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/src/ast/parser.rs')
-rw-r--r--compiler/src/ast/parser.rs16
1 files changed, 10 insertions, 6 deletions
diff --git a/compiler/src/ast/parser.rs b/compiler/src/ast/parser.rs
index 83e48b8..263e5b7 100644
--- a/compiler/src/ast/parser.rs
+++ b/compiler/src/ast/parser.rs
@@ -12,13 +12,17 @@ fn parse_number(number: &str) -> Result<Atom, Error> {
12 let is_float = number.bytes().any(|b| matches!(b, b'.' | b'e' | b'E')) 12 let is_float = number.bytes().any(|b| matches!(b, b'.' | b'e' | b'E'))
13 || matches!(number, "inf" | "+inf" | "-inf" | "nan"); 13 || matches!(number, "inf" | "+inf" | "-inf" | "nan");
14 14
15 let atom = if is_float { 15 if is_float {
16 Atom::Float(number.parse()?) 16 match number.parse() {
17 Ok(ok) => Ok(Atom::Float(ok)),
18 Err(err) => Err(Error::InvalidFloatLiteral(number.into(), err)),
19 }
17 } else { 20 } else {
18 Atom::Integer(number.parse()?) 21 match number.parse() {
19 }; 22 Ok(ok) => Ok(Atom::Integer(ok)),
20 23 Err(err) => Err(Error::InvalidIntegerLiteral(number.into(), err)),
21 Ok(atom) 24 }
25 }
22} 26}
23 27
24fn parse_string(string: &str) -> Result<Atom, Error> { 28fn parse_string(string: &str) -> Result<Atom, Error> {