diff options
| -rw-r--r-- | compiler/src/ast/parser.rs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/compiler/src/ast/parser.rs b/compiler/src/ast/parser.rs index 89a1280..6b11cc6 100644 --- a/compiler/src/ast/parser.rs +++ b/compiler/src/ast/parser.rs | |||
| @@ -7,7 +7,8 @@ use crate::{ | |||
| 7 | }; | 7 | }; |
| 8 | 8 | ||
| 9 | fn parse_number(number: &str) -> Result<Atom, Error> { | 9 | fn parse_number(number: &str) -> Result<Atom, Error> { |
| 10 | let is_float = number.bytes().any(|b| matches!(b, b'.' | b'e' | b'E')); | 10 | let is_float = number.bytes().any(|b| matches!(b, b'.' | b'e' | b'E')) |
| 11 | || matches!(number, "inf" | "+inf" | "-inf" | "nan"); | ||
| 11 | 12 | ||
| 12 | let atom = if is_float { | 13 | let atom = if is_float { |
| 13 | Atom::Float(number.parse()?) | 14 | Atom::Float(number.parse()?) |
| @@ -52,6 +53,9 @@ fn parse_symbol(symbol: &str) -> Atom { | |||
| 52 | "true" => Atom::Bool(true), | 53 | "true" => Atom::Bool(true), |
| 53 | "false" => Atom::Bool(false), | 54 | "false" => Atom::Bool(false), |
| 54 | "nil" => Atom::Nil, | 55 | "nil" => Atom::Nil, |
| 56 | "inf" | "+inf" => Atom::Float(f64::INFINITY), | ||
| 57 | "-inf" => Atom::Float(f64::NEG_INFINITY), | ||
| 58 | "nan" => Atom::Float(f64::NAN), | ||
| 55 | _ => Atom::Symbol(symbol.into()), | 59 | _ => Atom::Symbol(symbol.into()), |
| 56 | } | 60 | } |
| 57 | } | 61 | } |
