I am trying to use nom5 to pass a number of the zinc format https://www.project-haystack.org/doc/Zinc
The number format can be like any of the following formats
1, -34, 10_000, 5.4e-45, -5.4e-45, 9.23kg, 74.2°F, 4min, INF, -INF, NaN
I believe the units can be anything if specified.
I have some examples of simple number passing like Parsing number with nom 5.0
fn number<'a>(i: &'a str) -> IResult<&'a str, Token, (&'a str, ErrorKind)> {
map(
tuple((
opt(char('-')),
many1(digit1),
opt(preceded(char('.'), many1(digit1)))
)),
|s| Token::Number(s)
)(i)
}
but I am not sure how to deal with the values possibly also being INF or -INF, NaN and having the possible addition of units.
How would I handle this case in nom ?
Thanks