diff options
Diffstat (limited to 'stdlib/source/lux/compiler/default/syntax.lux')
-rw-r--r-- | stdlib/source/lux/compiler/default/syntax.lux | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/stdlib/source/lux/compiler/default/syntax.lux b/stdlib/source/lux/compiler/default/syntax.lux index 0497f55a2..5b20dcff5 100644 --- a/stdlib/source/lux/compiler/default/syntax.lux +++ b/stdlib/source/lux/compiler/default/syntax.lux @@ -184,7 +184,7 @@ "u" (do p.Monad<Parser> [code (l.between 1 4 l.hexadecimal)] - (wrap (case (|> code (format "+") (:: number.Hex@Codec<Text,Nat> decode)) + (wrap (case (:: number.Hex@Codec<Text,Nat> decode code) (#.Right value) [(n/+ 2 (text.size code)) (text.from-code value)] @@ -207,6 +207,8 @@ (l.and l.decimal (l.some rich-digit))) +(def: sign^ (l.one-of "+-")) + (do-template [<name> <tag> <lexer> <codec>] [(def: #export (<name> where) (-> Cursor (l.Lexer [Cursor Code])) @@ -221,8 +223,7 @@ [where (<tag> value)]]))))] [int #.Int - (l.and (p.default "" (l.one-of "-")) - rich-digits^) + (l.and sign^ rich-digits^) number.Codec<Text,Int>] [rev #.Rev @@ -259,8 +260,7 @@ (def: (normal-nat where) (-> Cursor (l.Lexer [Cursor Code])) (do p.Monad<Parser> - [chunk (l.and (l.one-of "+") - rich-digits^)] + [chunk rich-digits^] (case (:: number.Codec<Text,Nat> decode chunk) (#.Left error) (p.fail error) @@ -278,14 +278,14 @@ (-> Cursor (l.Lexer [Cursor Code])) (do p.Monad<Parser> [chunk ($_ l.and - (p.default "" (l.one-of "-")) + sign^ rich-digits^ (l.one-of ".") rich-digits^ (p.default "" ($_ l.and (l.one-of "eE") - (p.default "" (l.one-of "+-")) + sign^ rich-digits^)))] (case (:: number.Codec<Text,Frac> decode chunk) (#.Left error) |