From 77231e2aea26efa71fc657f0b1f96b1a35bcc916 Mon Sep 17 00:00:00 2001 From: Mathieu Poumeyrol Date: Thu, 31 Aug 2023 09:10:27 +0200 Subject: [PATCH] parse inf and -inf in nnef --- nnef/src/ast/parse.rs | 2 +- nnef/src/deser.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/nnef/src/ast/parse.rs b/nnef/src/ast/parse.rs index ab92a957be..81b50bbdca 100644 --- a/nnef/src/ast/parse.rs +++ b/nnef/src/ast/parse.rs @@ -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) } diff --git a/nnef/src/deser.rs b/nnef/src/deser.rs index 6c85aefd14..047ec8dfbe 100644 --- a/nnef/src/deser.rs +++ b/nnef/src/deser.rs @@ -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::() .map(Value::Scalar) .with_context(|| format!("Can not parse {f} as f32"))