diff options
author | Eduardo Julian | 2016-12-22 00:35:56 -0400 |
---|---|---|
committer | Eduardo Julian | 2016-12-22 00:35:56 -0400 |
commit | bb7adb6ddc72c8fba6c868b396dbb31e53224ee9 (patch) | |
tree | 7d2dcb2f4f7642d450798dc548ee96da05886ae4 | |
parent | 5becc5d52eb60fd69e11d6824f9aa6634a94b38c (diff) |
- Fixed a bug when parsing JSON numbers.
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/lux/data/format/json.lux | 25 |
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) |