Skip to content

Commit

Permalink
Allow scientific notation without + or - as these are optional. (#31)
Browse files Browse the repository at this point in the history
1e16 and 1e+!6 are both valid.

Co-authored-by: Paul Roskell <[email protected]>
  • Loading branch information
BlurrechDev and Paul Roskell authored Dec 5, 2023
1 parent addc725 commit 0fd0485
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion src/tokenizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 0fd0485

Please sign in to comment.