Skip to content

Commit

Permalink
Passing all tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex-Fischman committed Oct 21, 2024
1 parent de5f007 commit b8b976b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/ast/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -754,14 +754,20 @@ fn unum(ctx: &Context) -> Res<usize> {
}

fn r#f64(ctx: &Context) -> Res<OrderedFloat<f64>> {
use std::num::FpCategory::*;
let (_, span, next) = ident(ctx)?;
match span.string() {
"NaN" => Ok((OrderedFloat(f64::NAN), span, next)),
"inf" => Ok((OrderedFloat(f64::INFINITY), span, next)),
"-inf" => Ok((OrderedFloat(f64::NEG_INFINITY), span, next)),
_ => match span.string().parse::<f64>() {
Ok(x) => Ok((OrderedFloat(x), span, next)),
Err(_) => Err(ParseError::Float(span)),
// Rust will parse "infinity" as a float, which we don't want
// we're only using `parse` to avoid implementing it ourselves anyway
Ok(x) => match x.classify() {
Nan | Infinite => Err(ParseError::Float(span)),
Zero | Subnormal | Normal => Ok((OrderedFloat(x), span, next)),
},
},
}
}
Expand Down

0 comments on commit b8b976b

Please sign in to comment.