From 2d7df6950786b675fe24aa1bced2e5c11e3db91f Mon Sep 17 00:00:00 2001 From: Kevin Mehall Date: Mon, 5 Mar 2018 16:16:46 -0800 Subject: [PATCH] Avoid duplicate effort when parsing floats in the EDN parser. --- edn/src/edn.rustpeg | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/edn/src/edn.rustpeg b/edn/src/edn.rustpeg index 51f76310..3848a0fa 100644 --- a/edn/src/edn.rustpeg +++ b/edn/src/edn.rustpeg @@ -120,14 +120,8 @@ pub integer -> ValueAndSpan = } } -frac = sign? digit+ "." digit+ -exp = sign? digit+ ("e" / "E") sign? digit+ -frac_exp = sign? digit+ "." digit+ ("e" / "E") sign? digit+ - -// The order here is important - frac_exp must come before (exp / frac) or the -// parser assumes exp or frac when the float is really a frac_exp and fails pub float -> ValueAndSpan = - start:#position f:$( frac_exp / exp / frac ) end:#position { + start:#position f:$(sign? digit+ ("." digit+)? (("e" / "E") sign? digit+)?) end:#position { ValueAndSpan { inner: SpannedValue::Float(OrderedFloat(f.parse::().unwrap())), span: Span::new(start, end)