Skip to content

Commit ffe1260

Browse files
MaybeJustJamesjamesdbrock
authored andcommitted
A decimal exponent is not required for a number
This ensures that a decimal exponent is optional
1 parent 2aad875 commit ffe1260

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/Parsing/String/Basic.purs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ number =
120120
numberRegex :: forall m. ParserT String m String
121121
numberRegex = either unsafeCrashWith identity $ regex pattern mempty
122122
where
123-
pattern = "[+-]?[0-9]*(\\.[0-9]*)?([eE][+-]?[0-9]*(\\.[0-9]*))?"
123+
pattern = "[+-]?[0-9]*(\\.[0-9]*)?([eE][+-]?[0-9]*(\\.[0-9]*)?)?"
124124

125125
-- | Parser based on the __Data.Int.fromString__ function.
126126
-- |

test/Main.purs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,11 @@ main = do
726726
, expected: Right (-0.3)
727727
}
728728

729+
assertEqual' "number xEy"
730+
{ actual: runParser "2e1" number
731+
, expected: Right 20.0
732+
}
733+
729734
-- test from issue #73
730735
assertEqual' "number 2"
731736
{ actual: runParser "0.7531531167929774" number

0 commit comments

Comments
 (0)