aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source
diff options
context:
space:
mode:
authorEduardo Julian2016-12-22 00:35:56 -0400
committerEduardo Julian2016-12-22 00:35:56 -0400
commitbb7adb6ddc72c8fba6c868b396dbb31e53224ee9 (patch)
tree7d2dcb2f4f7642d450798dc548ee96da05886ae4 /stdlib/source
parent5becc5d52eb60fd69e11d6824f9aa6634a94b38c (diff)
- Fixed a bug when parsing JSON numbers.
Diffstat (limited to '')
-rw-r--r--stdlib/source/lux/data/format/json.lux25
1 files changed, 16 insertions, 9 deletions
diff --git a/stdlib/source/lux/data/format/json.lux b/stdlib/source/lux/data/format/json.lux
index 1b2c65f97..43b029f60 100644
--- a/stdlib/source/lux/data/format/json.lux
+++ b/stdlib/source/lux/data/format/json.lux
@@ -243,18 +243,25 @@
(def: number~
(Lexer Number)
(do Monad<Lexer>
- [?sign (: (Lexer (Maybe Text))
- (lexer;opt (lexer;text "-")))
+ [?sign (: (Lexer Text)
+ (lexer;default ""
+ (lexer;text "-")))
digits (: (Lexer Text)
(lexer;many' lexer;digit))
- ?decimals (: (Lexer (Maybe Text))
- (lexer;opt (do @
- [_ (lexer;text ".")]
- (lexer;many' lexer;digit))))]
+ decimals (: (Lexer Text)
+ (lexer;default "0"
+ (do @
+ [_ (lexer;text ".")]
+ (lexer;many' lexer;digit))))
+ exp (: (Lexer Text)
+ (lexer;default ""
+ (do @
+ [mark (lexer;either (lexer;text "e") (lexer;text "E"))
+ sign (lexer;default "" (lexer;text "-"))
+ offset (lexer;many' lexer;digit)]
+ (wrap (format mark sign offset)))))]
(case (: (Error Real)
- (Real/decode (format (default "" ?sign)
- digits "."
- (default "0" ?decimals))))
+ (Real/decode (format ?sign digits "." decimals exp)))
(#;Left message)
(lexer;fail message)