From c3cdaad1d13f38ec926e7113ae95a25611a04053 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Mon, 30 Jul 2018 21:27:26 -0400 Subject: Updating new-luxc to latest Lux changes [Part 1]. --- .../lux/compiler/default/phase/synthesis.lux | 3 ++- .../lux/compiler/default/phase/translation.lux | 15 ++++++++++++- stdlib/source/lux/data/text/unicode.lux | 16 +++++++++++--- stdlib/source/lux/math/random.lux | 25 +++++++++++----------- 4 files changed, 42 insertions(+), 17 deletions(-) (limited to 'stdlib') diff --git a/stdlib/source/lux/compiler/default/phase/synthesis.lux b/stdlib/source/lux/compiler/default/phase/synthesis.lux index 99111d2a7..2ee018be4 100644 --- a/stdlib/source/lux/compiler/default/phase/synthesis.lux +++ b/stdlib/source/lux/compiler/default/phase/synthesis.lux @@ -32,7 +32,7 @@ (type: #export Primitive (#Bit Bit) - (#I64 I64) + (#I64 (I64 Any)) (#F64 Frac) (#Text Text)) @@ -151,6 +151,7 @@ [(template: #export ( content) ( content))] + [path/bind #..Bind] [path/alt #..Alt] [path/seq #..Seq] [path/then #..Then] diff --git a/stdlib/source/lux/compiler/default/phase/translation.lux b/stdlib/source/lux/compiler/default/phase/translation.lux index e79645e63..d8a58ca84 100644 --- a/stdlib/source/lux/compiler/default/phase/translation.lux +++ b/stdlib/source/lux/compiler/default/phase/translation.lux @@ -56,7 +56,9 @@ (: (-> Text expression (Error Any)) evaluate!) (: (-> Text statement (Error Any)) - execute!)) + execute!) + (: (-> Name expression (Error Any)) + define!)) (type: #export (Buffer statement) (Row [Name statement])) @@ -194,6 +196,17 @@ [execute! statement] ) +(def: #export (define! name code) + (All [anchor expression statement] + (-> Name expression (Operation anchor expression statement Any))) + (function (_ (^@ stateE [bundle state])) + (case (:: (get@ #host state) define! name code) + (#error.Error error) + (ex.throw cannot-interpret error) + + (#error.Success output) + (#error.Success [stateE output])))) + (def: #export (save! name code) (All [anchor expression statement] (-> Name statement (Operation anchor expression statement Any))) diff --git a/stdlib/source/lux/data/text/unicode.lux b/stdlib/source/lux/data/text/unicode.lux index ebd54c02b..4cc1f66bc 100644 --- a/stdlib/source/lux/data/text/unicode.lux +++ b/stdlib/source/lux/data/text/unicode.lux @@ -59,6 +59,7 @@ (do-template [ ] [(def: #export Segment (..segment (hex ) (hex )))] + ## Normal segments [basic-latin "0000" "007F"] [latin-1-supplement "00A0" "00FF"] [latin-extended-a "0100" "017F"] @@ -181,6 +182,10 @@ [cjk-unified-ideographs-extension-b "20000" "2A6DF"] [cjk-compatibility-ideographs-supplement "2F800" "2FA1F"] [tags "E0000" "E007F"] + + ## Specialized segments + [basic-latin/upper-alpha "0041" "005A"] + [basic-latin/lower-alpha "0061" "007A"] ) (type: #export Set (Tree Segment [])) @@ -342,6 +347,11 @@ Set (finger.branch (set half/0) (set half/1))) -(def: #export ascii - Set - (set (list basic-latin))) +(do-template [ ] + [(def: #export Set (set ))] + + [ascii (list basic-latin)] + [ascii/alpha (list basic-latin/upper-alpha basic-latin/lower-alpha)] + [ascii/upper-alpha (list basic-latin/upper-alpha)] + [ascii/lower-alpha (list basic-latin/lower-alpha)] + ) diff --git a/stdlib/source/lux/math/random.lux b/stdlib/source/lux/math/random.lux index e441fc0f2..826846aac 100644 --- a/stdlib/source/lux/math/random.lux +++ b/stdlib/source/lux/math/random.lux @@ -99,17 +99,15 @@ (i64.left-shift 32) ("lux i64 +" right))]))) -(def: #export nat - (Random Nat) - (:: Monad map .nat ..i64)) - -(def: #export int - (Random Int) - (:: Monad map .int ..i64)) +(do-template [ ] + [(def: #export + (Random ) + (:: Monad map ..i64))] -(def: #export rev - (Random Rev) - (:: Monad map .rev ..i64)) + [nat Nat .nat] + [int Int .int] + [rev Rev .rev] + ) (def: #export frac (Random Frac) @@ -143,8 +141,11 @@ (-> Nat (Random Text)) (text (char )))] - [unicode unicode.full] - [ascii unicode.ascii] + [unicode unicode.full] + [ascii unicode.ascii] + [ascii/alpha unicode.ascii/alpha] + [ascii/upper-alpha unicode.ascii/upper-alpha] + [ascii/lower-alpha unicode.ascii/lower-alpha] ) (do-template [ ] -- cgit v1.2.3