Leading -'s are ignored in the int/float parsers, meaning negative inputs will fail! This is an easy fix, we can take the int/float parsers we have, move them into int_help/float_help and do:
pub fn int() -> Parser(Int, ctx) {
one_of[
// Attempt to parse a leading `-` and then negate the resulting integer.
succeed(int.negate)
|> drop(grapheme("-"))
|> keep(int_help()),
// No leading `-` was found so just trying parsing a regular integer.
int_help()
])
}
Leading
-
's are ignored in the int/float parsers, meaning negative inputs will fail! This is an easy fix, we can take the int/float parsers we have, move them intoint_help
/float_help
and do: