From 324665cef68fa326d358733d36ed20feba5dbbd6 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Wed, 22 Aug 2018 23:25:04 -0400 Subject: No more escaping of unicode. --- stdlib/source/lux/compiler/default/syntax.lux | 25 ------------------------- stdlib/source/lux/data/text/regex.lux | 10 +++++----- stdlib/source/lux/macro/poly.lux | 4 ++-- 3 files changed, 7 insertions(+), 32 deletions(-) (limited to 'stdlib/source') 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 - [code (l.between 1 4 l.hexadecimal)] - (wrap (case (:: number.Hex@Codec 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 )) - (case (:: number.Hex@Codec decode (!clip 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)] + ["." number (#+ hex) ("int/." Codec)] [collection ["." list ("list/." Fold Monad)]]] ["." 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)] ["e" error] - ["." number ("nat/." Codec)] + ["." number (#+ hex) ("nat/." Codec)] ["." text ("text/." Monoid) 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]))) -- cgit v1.2.3