diff options
Diffstat (limited to 'stdlib')
-rw-r--r-- | stdlib/source/lux/compiler/default/syntax.lux | 25 | ||||
-rw-r--r-- | stdlib/source/lux/data/text/regex.lux | 10 | ||||
-rw-r--r-- | stdlib/source/lux/macro/poly.lux | 4 | ||||
-rw-r--r-- | stdlib/test/test/lux/data/text/regex.lux | 9 | ||||
-rw-r--r-- | stdlib/test/test/lux/math/logic/fuzzy.lux | 8 |
5 files changed, 16 insertions, 40 deletions
diff --git a/stdlib/source/lux/compiler/default/syntax.lux b/stdlib/source/lux/compiler/default/syntax.lux index 89087d482..dc22de5d0 100644 --- a/stdlib/source/lux/compiler/default/syntax.lux +++ b/stdlib/source/lux/compiler/default/syntax.lux @@ -129,8 +129,6 @@ ## Escaped character sequences follow the usual syntax of ## back-slash followed by a letter (e.g. \n). -## Unicode escapes are possible, with hexadecimal sequences between 1 -## and 4 characters long (e.g. \u12aB). ## Escaped characters may show up in Char and Text literals. (def: escaped-char^ (Lexer [Nat Text]) @@ -143,17 +141,6 @@ (^ (static ..text-delimiter)) (wrap [2 ..text-delimiter]) (^ (static ..escape)) (wrap [2 ..escape]) - ## Handle unicode escapes. - "u" - (do p.Monad<Parser> - [code (l.between 1 4 l.hexadecimal)] - (wrap (case (:: number.Hex@Codec<Text,Nat> decode code) - (#.Right value) - [("lux i64 +" 2 (text.size code)) (text.from-code value)] - - _ - (undefined)))) - _ (p.fail (format "Invalid escaping syntax: " (%t code))))))) @@ -634,18 +621,6 @@ _ (ex.throw invalid-escape-syntax []))) - ## Handle unicode escapes. - (^ (char "u")) - (if (!i/< (:coerce Int end) - (:coerce Int <escape-end>)) - (case (:: number.Hex@Codec<Text,Nat> decode (!clip <escape-start> <escape-end> source-code)) - (#error.Success value) - (!find-next-escape 6 next-escape end source-code total (text.from-code value)) - - (#error.Error error) - (#error.Error error)) - (ex.throw invalid-escape-syntax [])) - _ (ex.throw invalid-escape-syntax [])))))) diff --git a/stdlib/source/lux/data/text/regex.lux b/stdlib/source/lux/data/text/regex.lux index a5409438e..e491873dc 100644 --- a/stdlib/source/lux/data/text/regex.lux +++ b/stdlib/source/lux/data/text/regex.lux @@ -7,7 +7,7 @@ ["." product] ["e" error] ["." maybe] - ["." number ("int/." Codec<Text,Int>)] + ["." number (#+ hex) ("int/." Codec<Text,Int>)] [collection ["." list ("list/." Fold<List> Monad<List>)]]] ["." macro (#+ with-gensyms) @@ -126,12 +126,12 @@ (def: ascii^ (l.Lexer Text) - (l.range (char "\u0000") (char "\u007F"))) + (l.range (hex "0") (hex "7F"))) (def: control^ (l.Lexer Text) - (p.either (l.range (char "\u0000") (char "\u001F")) - (l.one-of "\u007F"))) + (p.either (l.range (hex "0") (hex "1F")) + (l.one-of (//.from-code (hex "7F"))))) (def: punct^ (l.Lexer Text) @@ -144,7 +144,7 @@ (def: print^ (l.Lexer Text) (p.either graph^ - (l.one-of "\u0020"))) + (l.one-of (//.from-code (hex "20"))))) (def: re-system-class^ (l.Lexer Code) diff --git a/stdlib/source/lux/macro/poly.lux b/stdlib/source/lux/macro/poly.lux index 72a56b81d..7b3bc49a2 100644 --- a/stdlib/source/lux/macro/poly.lux +++ b/stdlib/source/lux/macro/poly.lux @@ -12,7 +12,7 @@ ["." maybe] [name ("name/." Codec<Text,Name>)] ["e" error] - ["." number ("nat/." Codec<Text,Nat>)] + ["." number (#+ hex) ("nat/." Codec<Text,Nat>)] ["." text ("text/." Monoid<Text>) format] [collection @@ -131,7 +131,7 @@ (def: (label idx) (-> Nat Code) - (code.local-identifier (text/compose "label\u0000" (nat/encode idx)))) + (code.local-identifier ($_ text/compose "label" text.tab (nat/encode idx)))) (def: #export (with-extension type poly) (All [a] (-> Type (Poly a) (Poly [Code a]))) diff --git a/stdlib/test/test/lux/data/text/regex.lux b/stdlib/test/test/lux/data/text/regex.lux index 7a6e88d33..7c54d8385 100644 --- a/stdlib/test/test/lux/data/text/regex.lux +++ b/stdlib/test/test/lux/data/text/regex.lux @@ -5,6 +5,7 @@ pipe ["p" parser]] [data + [number (#+ hex)] ["." text ("text/." Equivalence<Text>) format ["." lexer (#+ Lexer)] @@ -121,9 +122,9 @@ (should-fail (&.regex "\\p{Blank}") ".")) (and (should-pass (&.regex "\\p{ASCII}") text.tab) - (should-fail (&.regex "\\p{ASCII}") "\u1234")) + (should-fail (&.regex "\\p{ASCII}") (text.from-code (hex "1234")))) - (and (should-pass (&.regex "\\p{Contrl}") "\u0012") + (and (should-pass (&.regex "\\p{Contrl}") (text.from-code (hex "12"))) (should-fail (&.regex "\\p{Contrl}") "a")) (and (should-pass (&.regex "\\p{Punct}") "@") @@ -132,8 +133,8 @@ (and (should-pass (&.regex "\\p{Graph}") "@") (should-fail (&.regex "\\p{Graph}") " ")) - (and (should-pass (&.regex "\\p{Print}") "\u0020") - (should-fail (&.regex "\\p{Print}") "\u1234")) + (and (should-pass (&.regex "\\p{Print}") (text.from-code (hex "20"))) + (should-fail (&.regex "\\p{Print}") (text.from-code (hex "1234")))) )) )) diff --git a/stdlib/test/test/lux/math/logic/fuzzy.lux b/stdlib/test/test/lux/math/logic/fuzzy.lux index fe36a58c5..38f1cc75a 100644 --- a/stdlib/test/test/lux/math/logic/fuzzy.lux +++ b/stdlib/test/test/lux/math/logic/fuzzy.lux @@ -153,13 +153,13 @@ [#let [set-10 (set.from-list number.Hash<Nat> (list.n/range 0 10))] sample (|> r.nat (:: @ map (n/% 20)))] ($_ seq - (test "Values that satisfy a predicate have membership = 1. - Values that don't have membership = 0." + (test (format "Values that satisfy a predicate have membership = 1." + "Values that don't have membership = 0.") (bit/= (r/= _.true (&.membership sample (&.from-predicate n/even?))) (n/even? sample))) - (test "Values that belong to a set have membership = 1. - Values that don't have membership = 0." + (test (format "Values that belong to a set have membership = 1." + "Values that don't have membership = 0.") (bit/= (r/= _.true (&.membership sample (&.from-set set-10))) (set.member? set-10 sample))) )))) |