aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEduardo Julian2021-02-24 16:39:42 -0400
committerEduardo Julian2021-02-24 16:39:42 -0400
commitae7fc0207c8d3281882261642f6a8e0579985aa0 (patch)
treecd7e6202e4e9fb5c9d8db557a5cd805978669c76
parent565e7fae85379e4d2e4daacc51eb1f8796c738c1 (diff)
Done with Python.
-rw-r--r--compilers.md25
-rw-r--r--lux-bootstrapper/project.clj15
-rw-r--r--lux-cl/project.clj2
-rw-r--r--lux-js/project.clj2
-rw-r--r--lux-jvm/project.clj2
-rw-r--r--lux-lein/project.clj2
-rw-r--r--lux-lua/project.clj2
-rw-r--r--lux-php/project.clj4
-rw-r--r--lux-python/project.clj2
-rw-r--r--lux-python/source/program.lux108
-rw-r--r--lux-r/project.clj2
-rw-r--r--lux-ruby/project.clj2
-rw-r--r--lux-scheme/project.clj2
-rw-r--r--stdlib/project.clj2
-rw-r--r--stdlib/source/lux/math/number/nat.lux64
-rw-r--r--stdlib/source/lux/target/python.lux17
-rw-r--r--stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/python/common.lux4
-rw-r--r--stdlib/source/lux/tool/compiler/language/lux/phase/generation/python/runtime.lux68
-rw-r--r--stdlib/source/lux/world/file.lux2
-rw-r--r--stdlib/source/lux/world/program.lux10
-rw-r--r--stdlib/source/test/lux/data/text/encoding.lux14
-rw-r--r--stdlib/source/test/lux/data/text/unicode/block.lux19
-rw-r--r--stdlib/source/test/lux/locale/language.lux25
23 files changed, 246 insertions, 149 deletions
diff --git a/compilers.md b/compilers.md
index 1c2553fe9..beba9dcc3 100644
--- a/compilers.md
+++ b/compilers.md
@@ -145,31 +145,15 @@ cd ~/lux/lux-python/ \
&& lein clean \
&& lein lux build \
&& mv target/program.jar jvm_based_compiler.jar
-
-## Use JVM-based compiler to produce a Python-based compiler.
-cd ~/lux/lux-python/ \
-&& lein clean \
-&& time java -jar jvm_based_compiler.jar build --source ~/lux/lux-python/source --target ~/lux/lux-python/target --module program \
-&& mv target/program.py python_based_compiler.py
-&& python3 -m compileall python_based_compiler.py
-&& mv __pycache__/python_based_compiler.cpython-38.pyc python_based_compiler.pyc
-
-## Use Python-based compiler to produce another Python-based compiler.
-cd ~/lux/lux-python/ \
-&& lein clean \
-&& time python3 python_based_compiler.pyc build --source ~/lux/lux-python/source --target ~/lux/lux-python/target --module program \
-&& mv target/program.py lux.py
-&& python3 -m compileall lux.py
-&& mv __pycache__/lux.cpython-38.pyc lux.pyc
```
## Try
```
-## Compile Lux's Standard Library's tests using a Python-based compiler.
+## Compile Lux's Standard Library's tests using a JVM-based compiler.
cd ~/lux/stdlib/ \
&& lein clean \
-&& time python3 ~/lux/lux-python/lux.pyc build --source ~/lux/stdlib/source --target ~/lux/stdlib/target --module test/lux
+&& time java -jar ~/lux/lux-python/jvm_based_compiler.jar build --source ~/lux/stdlib/source --target ~/lux/stdlib/target --module test/lux
python3 ~/lux/stdlib/target/program.py
```
@@ -241,7 +225,10 @@ cd ~/lux/lux-php/ \
## Try
```
-cd ~/lux/lux-php/ && java -jar target/program.jar build --source ~/lux/stdlib/source --target ~/lux/stdlib/target --module test/lux
+## Compile Lux's Standard Library's tests using a JVM-based compiler.
+cd ~/lux/stdlib/ \
+&& lein clean \
+&& time java -jar ~/lux/lux-php/jvm_based_compiler.jar build --source ~/lux/stdlib/source --target ~/lux/stdlib/target --module test/lux
```
---
diff --git a/lux-bootstrapper/project.clj b/lux-bootstrapper/project.clj
index ac69dcd8b..b424ea8bc 100644
--- a/lux-bootstrapper/project.clj
+++ b/lux-bootstrapper/project.clj
@@ -2,7 +2,7 @@
:min-lein-version "2.1.0" ;; 2.1.0 introduced jar classifiers
:description "The JVM compiler for the Lux programming language."
:url "https://github.com/LuxLang/lux"
- :license {:name "Lux License v0.1"
+ :license {:name "Lux License v0.1.1"
:url "https://github.com/LuxLang/lux/blob/master/license.txt"}
:deploy-repositories [["releases" {:url "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
:creds :gpg}]
@@ -13,13 +13,14 @@
[:url "https://github.com/eduardoejp"]]]
:dependencies [[org.clojure/clojure "1.6.0"]
[org.clojure/core.match "0.2.1"]
- ;; [org.ow2.asm/asm-all "5.0.3"]
+ [org.ow2.asm/asm-all "5.0.3"]
- [org.ow2.asm/asm "7.3.1"]
- [org.ow2.asm/asm-commons "7.3.1"]
- [org.ow2.asm/asm-analysis "7.3.1"]
- [org.ow2.asm/asm-tree "7.3.1"]
- [org.ow2.asm/asm-util "7.3.1"]]
+ ;; [org.ow2.asm/asm "7.3.1"]
+ ;; [org.ow2.asm/asm-commons "7.3.1"]
+ ;; [org.ow2.asm/asm-analysis "7.3.1"]
+ ;; [org.ow2.asm/asm-tree "7.3.1"]
+ ;; [org.ow2.asm/asm-util "7.3.1"]
+ ]
:warn-on-reflection true
:repositories [["snapshots" "https://oss.sonatype.org/content/repositories/snapshots/"]
["releases" "https://oss.sonatype.org/service/local/staging/deploy/maven2/"]]
diff --git a/lux-cl/project.clj b/lux-cl/project.clj
index 4e9d6a68a..24ebf5589 100644
--- a/lux-cl/project.clj
+++ b/lux-cl/project.clj
@@ -6,7 +6,7 @@
(defproject com.github.luxlang/lux-cl #=(identity version)
:description "A Common Lisp compiler for Lux."
:url ~repo
- :license {:name "Lux License v0.1"
+ :license {:name "Lux License v0.1.1"
:url ~(str repo "/blob/master/license.txt")}
:scm {:name "git"
:url ~(str repo ".git")}
diff --git a/lux-js/project.clj b/lux-js/project.clj
index dfaaf2f5d..ad4ddf6f0 100644
--- a/lux-js/project.clj
+++ b/lux-js/project.clj
@@ -6,7 +6,7 @@
(defproject com.github.luxlang/lux-js #=(identity version)
:description "A JavaScript compiler for Lux."
:url ~repo
- :license {:name "Lux License v0.1"
+ :license {:name "Lux License v0.1.1"
:url ~(str repo "/blob/master/license.txt")}
:scm {:name "git"
:url ~(str repo ".git")}
diff --git a/lux-jvm/project.clj b/lux-jvm/project.clj
index ed3221411..e0606d0ab 100644
--- a/lux-jvm/project.clj
+++ b/lux-jvm/project.clj
@@ -7,7 +7,7 @@
(defproject com.github.luxlang/lux-jvm #=(identity version)
:description "A JVM compiler for Lux."
:url ~repo
- :license {:name "Lux License v0.1"
+ :license {:name "Lux License v0.1.1"
:url ~(str repo "/blob/master/license.txt")}
:plugins [[com.github.luxlang/lein-luxc ~version]]
:deploy-repositories [["releases" {:url ~sonatype-releases :creds :gpg}]
diff --git a/lux-lein/project.clj b/lux-lein/project.clj
index d81927bb2..c5c1b9090 100644
--- a/lux-lein/project.clj
+++ b/lux-lein/project.clj
@@ -1,7 +1,7 @@
(defproject com.github.luxlang/lein-luxc "0.6.0-SNAPSHOT"
:description "The Leiningen plugin for the Lux programming language."
:url "https://github.com/LuxLang/lein-luxc"
- :license {:name "Lux License v0.1"
+ :license {:name "Lux License v0.1.1"
:url "https://github.com/LuxLang/lux/blob/master/license.txt"}
:dependencies [[org.clojure/clojure "1.6.0"]]
:deploy-repositories [["releases" {:url "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
diff --git a/lux-lua/project.clj b/lux-lua/project.clj
index a97f77bd9..212304338 100644
--- a/lux-lua/project.clj
+++ b/lux-lua/project.clj
@@ -6,7 +6,7 @@
(defproject com.github.luxlang/lux-lua #=(identity version)
:description "A Lua compiler for Lux."
:url ~repo
- :license {:name "Lux License v0.1"
+ :license {:name "Lux License v0.1.1"
:url ~(str repo "/blob/master/license.txt")}
:scm {:name "git"
:url ~(str repo ".git")}
diff --git a/lux-php/project.clj b/lux-php/project.clj
index 8dfe91d27..24d36cfa6 100644
--- a/lux-php/project.clj
+++ b/lux-php/project.clj
@@ -4,9 +4,9 @@
(def sonatype-snapshots "https://oss.sonatype.org/content/repositories/snapshots/")
(defproject com.github.luxlang/lux-php #=(identity version)
- :description "A Ruby compiler for Lux."
+ :description "A PHP compiler for Lux."
:url ~repo
- :license {:name "Lux License v0.1"
+ :license {:name "Lux License v0.1.1"
:url ~(str repo "/blob/master/license.txt")}
:scm {:name "git"
:url ~(str repo ".git")}
diff --git a/lux-python/project.clj b/lux-python/project.clj
index 887cd2b89..88f4cec40 100644
--- a/lux-python/project.clj
+++ b/lux-python/project.clj
@@ -6,7 +6,7 @@
(defproject com.github.luxlang/lux-python #=(identity version)
:description "A Python compiler for Lux."
:url ~repo
- :license {:name "Lux License v0.1"
+ :license {:name "Lux License v0.1.1"
:url ~(str repo "/blob/master/license.txt")}
:scm {:name "git"
:url ~(str repo ".git")}
diff --git a/lux-python/source/program.lux b/lux-python/source/program.lux
index 4fae4b331..166dee982 100644
--- a/lux-python/source/program.lux
+++ b/lux-python/source/program.lux
@@ -42,7 +42,7 @@
[analysis
[macro (#+ Expander)]]
[phase
- ["." extension (#+ Extender Handler)
+ ["." extension (#+ Bundle Extender Handler)
["#/." bundle]
["." analysis #_
["#" python]]
@@ -100,6 +100,8 @@
["#::."
(__call__ [[org/python/core/PyObject]] #try org/python/core/PyObject)])
+ (import: org/python/core/ThreadState)
+
(import: org/python/core/PyArray
["#::."
(new [(java/lang/Class java/lang/Object) java/lang/Object])
@@ -352,30 +354,86 @@
_.none)))))
(for {@.old
- (def: extender
- Extender
- ## TODO: Stop relying on coercions ASAP.
- (<| (:coerce Extender)
- (function (@self handler))
- (:coerce Handler)
- (function (@self name phase))
- (:coerce Phase)
- (function (@self archive parameters))
- (:coerce Operation)
- (function (@self state))
- (:coerce Try)
- try.assume
- (:coerce Try)
- (do try.monad
- [handler (try.from_maybe (..ensure_function handler))
- output (org/python/core/PyFunction::__call__ (|> (host.array org/python/core/PyObject 5)
- (host.array_write 0 (org/python/core/PyString::new name))
- (host.array_write 1 (..to_host phase))
- (host.array_write 2 (..to_host archive))
- (host.array_write 3 (..to_host parameters))
- (host.array_write 4 (..to_host state)))
- handler)]
- (..read output))))
+ (as_is (exception: #export (cannot_parse_phase_inputs {arity Nat})
+ (exception.report
+ ["Arity" (%.nat arity)]))
+
+ (def: (host_phase phase)
+ (All [s i o]
+ (-> (Phase [Bundle s] i o)
+ org/python/core/PyObject))
+ (host.object [] org/python/core/PyObject []
+ []
+ ## Methods
+ (org/python/core/PyObject
+ [] (__call__ self
+ {_ org/python/core/ThreadState}
+ {input/0 org/python/core/PyObject})
+ org/python/core/PyObject
+ (case [(..read input/0)]
+ [(#try.Success input/0)]
+ (host_phase (:assume ((:coerce (-> Nat Nat Nat []) phase)
+ (:coerce Nat input/0))))
+
+ _
+ (error! (exception.construct ..cannot_parse_phase_inputs [1]))))
+
+ (org/python/core/PyObject
+ [] (__call__ self
+ {_ org/python/core/ThreadState}
+ {input/0 org/python/core/PyObject}
+ {input/1 org/python/core/PyObject})
+ org/python/core/PyObject
+ (case [(..read input/0) (..read input/1)]
+ [(#try.Success input/0) (#try.Success input/1)]
+ (host_phase (:assume ((:coerce (-> Nat Nat Nat []) phase)
+ (:coerce Nat input/0)
+ (:coerce Nat input/1))))
+
+ _
+ (error! (exception.construct ..cannot_parse_phase_inputs [2]))))
+
+ (org/python/core/PyObject
+ [] (__call__ self
+ {_ org/python/core/ThreadState}
+ {input/0 org/python/core/PyObject}
+ {input/1 org/python/core/PyObject}
+ {input/2 org/python/core/PyObject})
+ org/python/core/PyObject
+ (case [(..read input/0) (..read input/1) (..read input/2)]
+ [(#try.Success input/0) (#try.Success input/1) (#try.Success input/2)]
+ (..to_host ((:coerce (-> Nat Nat Nat []) phase)
+ (:coerce Nat input/0)
+ (:coerce Nat input/1)
+ (:coerce Nat input/2)))
+
+ _
+ (error! (exception.construct ..cannot_parse_phase_inputs [3]))))))
+
+ (def: extender
+ Extender
+ ## TODO: Stop relying on coercions ASAP.
+ (<| (:coerce Extender)
+ (function (@self handler))
+ (:coerce Handler)
+ (function (@self name phase))
+ (:coerce Phase)
+ (function (@self archive parameters))
+ (:coerce Operation)
+ (function (@self state))
+ (:coerce Try)
+ try.assume
+ (:coerce Try)
+ (do try.monad
+ [handler (try.from_maybe (..ensure_function handler))
+ output (org/python/core/PyFunction::__call__ (|> (host.array org/python/core/PyObject 5)
+ (host.array_write 0 (org/python/core/PyString::new name))
+ (host.array_write 1 (..host_phase phase))
+ (host.array_write 2 (..to_host archive))
+ (host.array_write 3 (..to_host parameters))
+ (host.array_write 4 (..to_host state)))
+ handler)]
+ (..read output)))))
@.python
(def: (extender handler)
diff --git a/lux-r/project.clj b/lux-r/project.clj
index 138d826fe..96e02e021 100644
--- a/lux-r/project.clj
+++ b/lux-r/project.clj
@@ -7,7 +7,7 @@
(defproject com.github.luxlang/lux-r #=(identity version)
:description "An R compiler for Lux."
:url ~repo
- :license {:name "Lux License v0.1"
+ :license {:name "Lux License v0.1.1"
:url ~(str repo "/blob/master/license.txt")}
:plugins [[com.github.luxlang/lein-luxc ~version]]
:deploy-repositories [["releases" {:url ~sonatype-releases :creds :gpg}]
diff --git a/lux-ruby/project.clj b/lux-ruby/project.clj
index 5da89c1a4..c6cdfb6d9 100644
--- a/lux-ruby/project.clj
+++ b/lux-ruby/project.clj
@@ -6,7 +6,7 @@
(defproject com.github.luxlang/lux-ruby #=(identity version)
:description "A Ruby compiler for Lux."
:url ~repo
- :license {:name "Lux License v0.1"
+ :license {:name "Lux License v0.1.1"
:url ~(str repo "/blob/master/license.txt")}
:scm {:name "git"
:url ~(str repo ".git")}
diff --git a/lux-scheme/project.clj b/lux-scheme/project.clj
index b5f22536e..ab96d66dc 100644
--- a/lux-scheme/project.clj
+++ b/lux-scheme/project.clj
@@ -6,7 +6,7 @@
(defproject com.github.luxlang/lux-scheme #=(identity version)
:description "A Scheme compiler for Lux."
:url ~repo
- :license {:name "Lux License v0.1"
+ :license {:name "Lux License v0.1.1"
:url ~(str repo "/blob/master/license.txt")}
:scm {:name "git"
:url ~(str repo ".git")}
diff --git a/stdlib/project.clj b/stdlib/project.clj
index 62474fea1..7905f82b3 100644
--- a/stdlib/project.clj
+++ b/stdlib/project.clj
@@ -5,7 +5,7 @@
(defproject com.github.luxlang/stdlib #=(identity version)
:url ~repo
- :license {:name "Lux License v0.1"
+ :license {:name "Lux License v0.1.1"
:url ~(str repo "/blob/master/license.txt")}
:plugins [[com.github.luxlang/lein-luxc ~version]]
:deploy-repositories [["releases" {:url ~sonatype-releases :creds :gpg}]
diff --git a/stdlib/source/lux/math/number/nat.lux b/stdlib/source/lux/math/number/nat.lux
index e3d8d8628..7edc60be4 100644
--- a/stdlib/source/lux/math/number/nat.lux
+++ b/stdlib/source/lux/math/number/nat.lux
@@ -305,38 +305,6 @@
(^or (^ (char "f")) (^ (char "F"))) (#.Some 15)
_ #.None))
-(structure: #export decimal
- (Codec Text Nat)
-
- (def: (encode value)
- (loop [input value
- output ""]
- (let [digit (decimal-character (..% 10 input))
- output' ("lux text concat" digit output)]
- (case (../ 10 input)
- 0
- output'
-
- input'
- (recur input' output')))))
-
- (def: (decode repr)
- (let [input-size ("lux text size" repr)]
- (with_expansions [<failure> (#try.Failure ("lux text concat" "Invalid decimal syntax for Nat: " repr))]
- (if (..> 0 input-size)
- (loop [idx 0
- output 0]
- (if (..< input-size idx)
- (case (decimal-value ("lux text char" idx repr))
- #.None
- <failure>
-
- (#.Some digit-value)
- (recur (inc idx)
- (|> output (..* 10) (..+ digit-value))))
- (#try.Success output)))
- <failure>)))))
-
(template [<shift> <struct> <to-character> <to-value> <error>]
[(structure: #export <struct>
(Codec Text Nat)
@@ -379,6 +347,38 @@
[4 hex hexadecimal-character hexadecimal-value "Invalid hexadecimal syntax for Nat: "]
)
+(structure: #export decimal
+ (Codec Text Nat)
+
+ (def: (encode value)
+ (loop [input value
+ output ""]
+ (let [digit (decimal-character (..% 10 input))
+ output' ("lux text concat" digit output)]
+ (case (../ 10 input)
+ 0
+ output'
+
+ input'
+ (recur input' output')))))
+
+ (def: (decode repr)
+ (let [input-size ("lux text size" repr)]
+ (with_expansions [<failure> (#try.Failure ("lux text concat" "Invalid decimal syntax for Nat: " repr))]
+ (if (..> 0 input-size)
+ (loop [idx 0
+ output 0]
+ (if (..< input-size idx)
+ (case (decimal-value ("lux text char" idx repr))
+ #.None
+ <failure>
+
+ (#.Some digit-value)
+ (recur (inc idx)
+ (|> output (..* 10) (..+ digit-value))))
+ (#try.Success output)))
+ <failure>)))))
+
(structure: #export hash
(Hash Nat)
diff --git a/stdlib/source/lux/target/python.lux b/stdlib/source/lux/target/python.lux
index e27ae9b83..1ae1cca64 100644
--- a/stdlib/source/lux/target/python.lux
+++ b/stdlib/source/lux/target/python.lux
@@ -1,5 +1,7 @@
(.module:
[lux (#- Location Code not or and list if cond int comment exec)
+ ["@" target]
+ ["." host]
[abstract
[equivalence (#+ Equivalence)]
[hash (#+ Hash)]
@@ -28,10 +30,21 @@
(-> Text Text)
(text.enclose ["(" ")"]))
+(for {@.old (as_is (host.import: java/lang/CharSequence)
+ (host.import: java/lang/String
+ ["#::."
+ (replace [java/lang/CharSequence java/lang/CharSequence] java/lang/String)]))}
+ (as_is))
+
(def: nest
(-> Text Text)
- (|>> (format text.new_line)
- (text.replace_all text.new_line (format text.new_line text.tab))))
+ (.let [nested_new_line (format text.new_line text.tab)]
+ (for {@.old (|>> (format text.new_line)
+ (:coerce java/lang/String)
+ (java/lang/String::replace (:coerce java/lang/CharSequence text.new_line)
+ (:coerce java/lang/CharSequence nested_new_line)))}
+ (|>> (format text.new_line)
+ (text.replace_all text.new_line nested_new_line)))))
(abstract: #export (Code brand)
Text
diff --git a/stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/python/common.lux b/stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/python/common.lux
index b87390e9a..d7133aa70 100644
--- a/stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/python/common.lux
+++ b/stdlib/source/lux/tool/compiler/language/lux/phase/extension/generation/python/common.lux
@@ -122,7 +122,9 @@
(/.install "-" (binary (product.uncurry _.-)))
(/.install "*" (binary (product.uncurry _.*)))
(/.install "/" (binary (product.uncurry _./)))
- (/.install "%" (binary (product.uncurry _.%)))
+ (/.install "%" (binary (function (_ [parameter subject])
+ (|> (_.__import__/1 (_.unicode "math"))
+ (_.do "fmod" (list subject parameter))))))
(/.install "=" (binary (product.uncurry _.=)))
(/.install "<" (binary (product.uncurry _.<)))
(/.install "i64" (unary _.int/1))
diff --git a/stdlib/source/lux/tool/compiler/language/lux/phase/generation/python/runtime.lux b/stdlib/source/lux/tool/compiler/language/lux/phase/generation/python/runtime.lux
index 6d218b137..22234bcc4 100644
--- a/stdlib/source/lux/tool/compiler/language/lux/phase/generation/python/runtime.lux
+++ b/stdlib/source/lux/tool/compiler/language/lux/phase/generation/python/runtime.lux
@@ -29,12 +29,12 @@
["$" version]
["#." synthesis (#+ Synthesis)]
["#." generation]
- ["//#" /// (#+ Output)
+ ["//#" ///
["#." phase]
[reference
[variable (#+ Register)]]
[meta
- [archive (#+ Archive)
+ [archive (#+ Output Archive)
["." artifact (#+ Registry)]]]]]])
(template [<name> <base>]
@@ -270,24 +270,48 @@
@sum//get
))
-(runtime: i64//top
+(runtime: i64//+limit
(|> (_.int +1)
(_.bit_shl (_.int +63))
(_.- (_.int +1))))
-(runtime: i64//bottom
+(runtime: i64//-limit
(_.- (|> (_.int +1)
(_.bit_shl (_.int +63)))
(_.int +0)))
+(runtime: i64//+iteration
+ (|> (_.int +1)
+ (_.bit_shl (_.int +64))))
+
+(runtime: i64//-iteration
+ (|> ..i64//+iteration
+ _.negate))
+
+(runtime: i64//+cap
+ (|> ..i64//+limit
+ (_.+ (_.int +1))))
+
+(runtime: i64//-cap
+ (|> ..i64//-limit
+ (_.- (_.int +1))))
+
(runtime: (i64//64 input)
- (_.return (<| (_.? (|> input (_.< ..i64//bottom))
- (|> input (_.- ..i64//bottom) (_.+ (_.int +1)) (_.+ i64//top) i64//64))
- (_.? (|> input (_.> ..i64//top))
- (|> input (_.- ..i64//top) (_.- (_.int +1)) (_.+ ..i64//bottom) i64//64))
- (for {@.python input}
- ## This +- is only necessary to guaranteed that values within the limits are always longs in Python 2
- (|> input (_.+ i64//top) (_.- ..i64//top))))))
+ (with_vars [temp]
+ (`` (<| (~~ (template [<scenario> <iteration> <cap> <entrance>]
+ [(_.if (|> input <scenario>)
+ ($_ _.then
+ (_.set (list temp) (_.% <iteration> input))
+ (_.return (_.? (|> temp <scenario>)
+ (|> temp (_.- <cap>) (_.+ <entrance>))
+ temp))))]
+
+ [(_.> ..i64//+limit) ..i64//+iteration ..i64//+cap ..i64//-limit]
+ [(_.< ..i64//-limit) ..i64//-iteration ..i64//-cap ..i64//+limit]
+ ))
+ (_.return (for {@.python input}
+ ## This +- is only necessary to guarantee that values within the limits are always longs in Python 2
+ (|> input (_.+ ..i64//+limit) (_.- ..i64//+limit))))))))
(runtime: i64//nat_top
(|> (_.int +1)
@@ -299,15 +323,17 @@
(runtime: (i64//left_shift param subject)
(_.return (|> subject
- ..as_nat
- (_.bit_shl param)
- ..as_nat
+ (_.bit_shl (_.% (_.int +64) param))
..i64//64)))
(runtime: (i64//right_shift param subject)
- (_.return (|> subject
- ..as_nat
- (_.bit_shr param))))
+ ($_ _.then
+ (_.set (list param) (_.% (_.int +64) param))
+ (_.return (_.? (_.= (_.int +0) param)
+ subject
+ (|> subject
+ ..as_nat
+ (_.bit_shr param))))))
(runtime: (i64//division param subject)
(with_vars [floored]
@@ -350,8 +376,12 @@
(def: runtime//i64
(Statement Any)
($_ _.then
- @i64//top
- @i64//bottom
+ @i64//+limit
+ @i64//-limit
+ @i64//+iteration
+ @i64//-iteration
+ @i64//+cap
+ @i64//-cap
@i64//64
@i64//nat_top
@i64//left_shift
diff --git a/stdlib/source/lux/world/file.lux b/stdlib/source/lux/world/file.lux
index 69f5a17db..972019c39 100644
--- a/stdlib/source/lux/world/file.lux
+++ b/stdlib/source/lux/world/file.lux
@@ -852,7 +852,7 @@
(..can_open
(function (create_file path)
(do {! io.monad}
- [file (..open [path "x"])]
+ [file (..open [path "w"])]
(case file
(#try.Success file)
(do (try.with !)
diff --git a/stdlib/source/lux/world/program.lux b/stdlib/source/lux/world/program.lux
index 7763bed2c..7a3d125a0 100644
--- a/stdlib/source/lux/world/program.lux
+++ b/stdlib/source/lux/world/program.lux
@@ -169,17 +169,15 @@
(import: (require [host.String] Any)))
@.python (as_is (import: os
- (#static getcwd [] #io host.String))
+ (#static getcwd [] #io host.String)
+ (#static _exit [host.Integer] #io Nothing))
(import: os/path
(#static expanduser [host.String] #io host.String))
(import: os/environ
(#static keys [] #io (Array host.String))
- (#static get [host.String] #io host.String))
-
- (import: sys
- (#static exit [host.Integer] #io Nothing)))
+ (#static get [host.String] #io host.String)))
@.lua (as_is (host.import: LuaFile
(read [host.String] #io #? host.String)
(close [] #io host.Boolean))
@@ -293,5 +291,5 @@
## else
(..default_exit! code))
- @.python (sys::exit code)
+ @.python (os::_exit [code])
@.lua (os/exit [code])}))))
diff --git a/stdlib/source/test/lux/data/text/encoding.lux b/stdlib/source/test/lux/data/text/encoding.lux
index c2b438232..9a9ba67cf 100644
--- a/stdlib/source/test/lux/data/text/encoding.lux
+++ b/stdlib/source/test/lux/data/text/encoding.lux
@@ -26,7 +26,7 @@
(with_expansions [<encodings> (as_is [all/a
[/.ascii]]
- [all/ibm<1000
+ [all/ibm<700
[/.ibm_37
/.ibm_273
/.ibm_277
@@ -40,8 +40,10 @@
/.ibm_420
/.ibm_424
/.ibm_437
- /.ibm_500
- /.ibm_737
+ /.ibm_500]]
+
+ [all/ibm<900
+ [/.ibm_737
/.ibm_775
/.ibm_833
/.ibm_834
@@ -64,8 +66,10 @@
/.ibm_870
/.ibm_871
/.ibm_874
- /.ibm_875
- /.ibm_918
+ /.ibm_875]]
+
+ [all/ibm>900
+ [/.ibm_918
/.ibm_921
/.ibm_922
/.ibm_930
diff --git a/stdlib/source/test/lux/data/text/unicode/block.lux b/stdlib/source/test/lux/data/text/unicode/block.lux
index d822a69d3..7f77aa34f 100644
--- a/stdlib/source/test/lux/data/text/unicode/block.lux
+++ b/stdlib/source/test/lux/data/text/unicode/block.lux
@@ -49,8 +49,9 @@
/.bengali
/.gurmukhi
/.gujarati
- /.oriya
- /.tamil
+ /.oriya]]
+ [blocks/1
+ [/.tamil
/.telugu
/.kannada
/.malayalam
@@ -72,7 +73,7 @@
/.tagbanwa
/.khmer
/.mongolian]]
- [blocks/1
+ [blocks/2
[/.limbu
/.tai_le
/.khmer_symbols
@@ -94,8 +95,9 @@
/.box_drawing
/.block_elements
/.geometric_shapes
- /.miscellaneous_symbols
- /.dingbats
+ /.miscellaneous_symbols]]
+ [blocks/3
+ [/.dingbats
/.miscellaneous_mathematical_symbols_a
/.supplemental_arrows_a
/.braille_patterns
@@ -112,8 +114,9 @@
/.bopomofo
/.hangul_compatibility_jamo
/.kanbun
- /.bopomofo_extended
- /.katakana_phonetic_extensions
+ /.bopomofo_extended]]
+ [blocks/4
+ [/.katakana_phonetic_extensions
/.enclosed_cjk_letters_and_months
/.cjk_compatibility
/.cjk_unified_ideographs_extension_a
@@ -128,7 +131,7 @@
/.private_use_area
/.cjk_compatibility_ideographs
/.alphabetic_presentation_forms]]
- [blocks/2
+ [blocks/5
[/.arabic_presentation_forms_a
/.variation_selectors
/.combining_half_marks
diff --git a/stdlib/source/test/lux/locale/language.lux b/stdlib/source/test/lux/locale/language.lux
index b3bfffc4e..9e49fbb1e 100644
--- a/stdlib/source/test/lux/locale/language.lux
+++ b/stdlib/source/test/lux/locale/language.lux
@@ -120,17 +120,17 @@
[languages/q [/.quechua]]
[languages/r [/.rajasthani /.rapanui /.rarotongan /.romance /.romansh
/.romany /.romanian /.rundi /.aromanian /.russian]]
- [languages/s [/.sandawe /.sango /.yakut /.south_american_indian /.salishan
- /.samaritan_aramaic /.sanskrit /.sasak /.santali /.sicilian
- /.scots /.selkup /.semitic /.old_irish /.sign
- /.shan /.sidamo /.sinhalese /.siouan /.sino_tibetan
- /.slavic /.slovak /.slovenian /.southern_sami /.northern_sami
- /.sami /.lule /.inari /.samoan /.skolt_sami
- /.shona /.sindhi /.soninke /.sogdian /.somali
- /.songhai /.southern_sotho /.spanish /.albanian /.sardinian
- /.sranan_tongo /.serbian /.serer /.nilo_saharan /.swati
- /.sukuma /.sundanese /.susu /.sumerian /.swahili
- /.swedish /.classical_syriac /.syriac]]
+ [languages/s0 [/.sandawe /.sango /.yakut /.south_american_indian /.salishan
+ /.samaritan_aramaic /.sanskrit /.sasak /.santali /.sicilian
+ /.scots /.selkup /.semitic /.old_irish /.sign
+ /.shan /.sidamo /.sinhalese /.siouan /.sino_tibetan
+ /.slavic /.slovak /.slovenian /.southern_sami /.northern_sami
+ /.sami /.lule /.inari /.samoan /.skolt_sami]]
+ [languages/s1 [/.shona /.sindhi /.soninke /.sogdian /.somali
+ /.songhai /.southern_sotho /.spanish /.albanian /.sardinian
+ /.sranan_tongo /.serbian /.serer /.nilo_saharan /.swati
+ /.sukuma /.sundanese /.susu /.sumerian /.swahili
+ /.swedish /.classical_syriac /.syriac]]
[languages/t [/.tahitian /.tai /.tamil /.tatar /.telugu
/.timne /.tereno /.tetum /.tajik /.tagalog
/.thai /.tigre /.tigrinya /.tiv /.tokelau
@@ -170,7 +170,8 @@
..languages/p
..languages/q
..languages/r
- ..languages/s
+ ..languages/s0
+ ..languages/s1
..languages/t
..languages/u
..languages/v