From 168d36d07b48d2d936de24aa69b8464e68992075 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Sat, 28 Jul 2018 15:51:48 -0400 Subject: Covered some missing bits. --- stdlib/source/lux.lux | 2 +- stdlib/source/lux/compiler/default/syntax.lux | 14 +++++++------- stdlib/source/lux/data/collection/list.lux | 2 +- stdlib/test/test/lux/data/number.lux | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) (limited to 'stdlib') diff --git a/stdlib/source/lux.lux b/stdlib/source/lux.lux index 109a590e3..34ceb43ba 100644 --- a/stdlib/source/lux.lux +++ b/stdlib/source/lux.lux @@ -2560,7 +2560,7 @@ (let' [loop ("lux check" (-> Nat Text Text) (function' recur [input output] (if (n/= 0 input) - (text/compose "|" output) + output (recur (n// 10 input) (text/compose (|> input (n/% 10) digit-to-text) output)))))] 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 [code (l.between 1 4 l.hexadecimal)] - (wrap (case (|> code (format "+") (:: number.Hex@Codec decode)) + (wrap (case (:: number.Hex@Codec 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 [ ] [(def: #export ( where) (-> Cursor (l.Lexer [Cursor Code])) @@ -221,8 +223,7 @@ [where ( value)]]))))] [int #.Int - (l.and (p.default "" (l.one-of "-")) - rich-digits^) + (l.and sign^ rich-digits^) number.Codec] [rev #.Rev @@ -259,8 +260,7 @@ (def: (normal-nat where) (-> Cursor (l.Lexer [Cursor Code])) (do p.Monad - [chunk (l.and (l.one-of "+") - rich-digits^)] + [chunk rich-digits^] (case (:: number.Codec decode chunk) (#.Left error) (p.fail error) @@ -278,14 +278,14 @@ (-> Cursor (l.Lexer [Cursor Code])) (do p.Monad [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 decode chunk) (#.Left error) diff --git a/stdlib/source/lux/data/collection/list.lux b/stdlib/source/lux/data/collection/list.lux index 09328def9..bbc649fb9 100644 --- a/stdlib/source/lux/data/collection/list.lux +++ b/stdlib/source/lux/data/collection/list.lux @@ -403,7 +403,7 @@ output' ("lux text concat" digit output) input' (n// 10 input)] (if (n/= 0 input') - ("lux text concat" "+" output') + output' (recur input' output'))))) (macro: #export (zip tokens state) diff --git a/stdlib/test/test/lux/data/number.lux b/stdlib/test/test/lux/data/number.lux index 36bc9a3f9..b5cf8e414 100644 --- a/stdlib/test/test/lux/data/number.lux +++ b/stdlib/test/test/lux/data/number.lux @@ -179,7 +179,7 @@ (r/= (oct ".615243") (oct ".615_243")) (f/= (oct "+6152.43") (oct "+615_2.43")))) (test "Hexadecimal." - (and (n/= (hex "|deadBEEF") (hex "|dead_BEEF")) - (i/= (hex "deadBEEF") (hex "dead_BEEF")) + (and (n/= (hex "deadBEEF") (hex "dead_BEEF")) + (i/= (hex "+deadBEEF") (hex "+dead_BEEF")) (r/= (hex ".deadBEEF") (hex ".dead_BEEF")) - (f/= (hex "deadBE.EF") (hex "dead_BE.EF")))))) + (f/= (hex "+deadBE.EF") (hex "+dead_BE.EF")))))) -- cgit v1.2.3