From 0fd0485e18a2d558d8c9b5398ad1aec2e3ae4fd3 Mon Sep 17 00:00:00 2001 From: Paul Roskell Date: Tue, 5 Dec 2023 14:30:19 +0000 Subject: [PATCH] Allow scientific notation without + or - as these are optional. (#31) 1e16 and 1e+!6 are both valid. Co-authored-by: Paul Roskell --- src/lib.rs | 3 ++- src/tokenizer.rs | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 58adc22..ff5a668 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1401,13 +1401,14 @@ mod tests { #[test] fn it_recognizes_scientific_notation() { - let input = "SELECT *, 1e-7 as small, 1e+7 as large FROM t"; + let input = "SELECT *, 1e-7 as small, 1e2 as medium, 1e+7 as large FROM t"; let options = FormatOptions::default(); let expected = indoc!( " SELECT *, 1e-7 as small, + 1e2 as medium, 1e+7 as large FROM t" diff --git a/src/tokenizer.rs b/src/tokenizer.rs index 49fd292..e31bfd6 100644 --- a/src/tokenizer.rs +++ b/src/tokenizer.rs @@ -393,7 +393,7 @@ fn scientific_notation(input: &str) -> IResult<&str, &str> { recognize(tuple(( alt((decimal_number, digit1)), tag("e"), - alt((tag("-"), tag("+"))), + alt((tag("-"), tag("+"), tag(""))), digit1, )))(input) }