Skip to content

Commit

Permalink
parse inf and -inf in nnef
Browse files Browse the repository at this point in the history
  • Loading branch information
kali committed Aug 31, 2023
1 parent f53bedf commit 77231e2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion nnef/src/ast/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ pub(super) fn numeric_literal(i: &str) -> IResult<&str, String> {
recognize(tuple((tag("."), digit0)))(i)
}
spaced(map(
recognize(tuple((opt(tag("-")), digit1, opt(frac_part), opt(exp_part)))),
recognize(tuple((opt(tag("-")), alt((digit1, tag("inf"))), opt(frac_part), opt(exp_part)))),
|s: &str| s.to_owned(),
))(i)
}
Expand Down
2 changes: 1 addition & 1 deletion nnef/src/deser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ impl RValue {
))
}
RValue::Literal(Literal::Numeric(f)) => {
if f.contains('.') || f.contains('e') {
if f.contains('.') || f.contains('e') || f == "inf" || f == "-inf" {
f.parse::<f32>()
.map(Value::Scalar)
.with_context(|| format!("Can not parse {f} as f32"))
Expand Down

0 comments on commit 77231e2

Please sign in to comment.