number.rs: Allow Plus-sign before radix marker

This commit is contained in:
John 2023-08-23 00:16:39 -05:00
parent 8c2f53f950
commit 8ea41b46f8

View File

@ -16,7 +16,8 @@ impl Parsable for Number {
fn parse<'text, T>(p: &Parser, stream: &mut T) -> Result<Self, Error>
where T: TokenStream<'text> {
use Type::*;
let negative = stream.expect(Minus).is_ok();
// The number is negative when it begins with a Minus, but Plus is also acceptable.
let negative = stream.expect_any_of([Minus, Plus]).map_or(false, |t| t.is_variant(Minus));
let radix = match stream
.expect_any_of([RadixMarkerHex, RadixMarkerDec, RadixMarkerOct, RadixMarkerBin])
.ok()