aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library/lux/tool/compiler
diff options
context:
space:
mode:
authorEduardo Julian2022-03-14 06:14:57 -0400
committerEduardo Julian2022-03-14 06:14:57 -0400
commit4965597043aca57a05760113f1851e96dad1eaf8 (patch)
tree8126d3e6394e38bc52918eea95a67546350bb95e /stdlib/source/library/lux/tool/compiler
parentcfd438517a46e025b15345e3570b02f5ea6165c0 (diff)
Leaner syntax for the "for" macro.
Diffstat (limited to 'stdlib/source/library/lux/tool/compiler')
-rw-r--r--stdlib/source/library/lux/tool/compiler/default/platform.lux46
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/js.lux2
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/lua.lux6
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/php.lux6
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/python.lux12
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/ruby.lux6
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/scheme.lux5
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua/common.lux2
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/runtime.lux8
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/runtime.lux2
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/reference.lux31
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/syntax.lux6
-rw-r--r--stdlib/source/library/lux/tool/compiler/meta/cache/module.lux2
-rw-r--r--stdlib/source/library/lux/tool/compiler/meta/io/archive.lux4
14 files changed, 70 insertions, 68 deletions
diff --git a/stdlib/source/library/lux/tool/compiler/default/platform.lux b/stdlib/source/library/lux/tool/compiler/default/platform.lux
index 1bccf29e7..6f4cd29e2 100644
--- a/stdlib/source/library/lux/tool/compiler/default/platform.lux
+++ b/stdlib/source/library/lux/tool/compiler/default/platform.lux
@@ -119,12 +119,12 @@
(do [! ..monad]
[_ (: (Async (Try Any))
(cache/module.enable! async.monad system context @module))
- _ (for [@.python (|> entry
- (the archive.#output)
- sequence.list
- (list.sub 128)
- (monad.each ! (monad.each ! write_artifact!))
- (: (Action (List (List Any)))))]
+ _ (for @.python (|> entry
+ (the archive.#output)
+ sequence.list
+ (list.sub 128)
+ (monad.each ! (monad.each ! write_artifact!))
+ (: (Action (List (List Any)))))
(|> entry
(the archive.#output)
sequence.list
@@ -776,12 +776,12 @@
(do !
[_ (let [report (..module_compilation_log module state)]
(with_expansions [<else> (in (debug.log! report))]
- (for [@.js (case console.default
- {.#None}
- <else>
-
- {.#Some console}
- (console.write_line report console))]
+ (for @.js (case console.default
+ {.#None}
+ <else>
+
+ {.#Some console}
+ (console.write_line report console))
<else>)))
.let [entry (has [archive.#module module.#descriptor descriptor.#references] all_dependencies entry)]
_ (..cache_module context platform @module $.key $.writer (:as (archive.Entry .Module) entry))]
@@ -795,17 +795,17 @@
[_ (cache/archive.cache! (the #&file_system platform) context archive)]
(async#in {try.#Failure error})))))))
- (for [@.old (as_is (def: Fake_State
- Type
- {.#Primitive (%.nat (static.random_nat)) (list)})
+ (for @.old (as_is (def: Fake_State
+ Type
+ {.#Primitive (%.nat (static.random_nat)) (list)})
- (def: Fake_Document
- Type
- {.#Primitive (%.nat (static.random_nat)) (list)})
+ (def: Fake_Document
+ Type
+ {.#Primitive (%.nat (static.random_nat)) (list)})
- (def: Fake_Object
- Type
- {.#Primitive (%.nat (static.random_nat)) (list)}))]
+ (def: Fake_Object
+ Type
+ {.#Primitive (%.nat (static.random_nat)) (list)}))
(as_is))
(def: (serial_compiler import context platform compilation_sources compiler)
@@ -820,8 +820,8 @@
compilation_sources
(the context.#host_module_extension context)
module)]
- (loop [customs (for [@.old (:as (List (///.Custom Fake_State Fake_Document Fake_Object))
- all_customs)]
+ (loop [customs (for @.old (:as (List (///.Custom Fake_State Fake_Document Fake_Object))
+ all_customs)
all_customs)]
(case customs
{.#End}
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/js.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/js.lux
index 9cb9fcf96..888c39155 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/js.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/js.lux
@@ -202,7 +202,7 @@
[.let [inputT (type.tuple (list.repeated arity Any))]
abstractionA (analysis/type.expecting (-> inputT Any)
(phase archive abstractionC))
- _ (analysis/type.inference (for [@.js ffi.Function]
+ _ (analysis/type.inference (for @.js ffi.Function
Any))]
(in {analysis.#Extension extension (list (analysis.nat arity)
abstractionA)})))]))
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/lua.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/lua.lux
index e65c2db5e..ca7dfe9bb 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/lua.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/lua.lux
@@ -27,15 +27,15 @@
["[0]" phase]]]]])
(def: Nil
- (for [@.lua ffi.Nil]
+ (for @.lua ffi.Nil
Any))
(def: Object
- (for [@.lua (type (ffi.Object Any))]
+ (for @.lua (type (ffi.Object Any))
Any))
(def: Function
- (for [@.lua ffi.Function]
+ (for @.lua ffi.Function
Any))
(def: array::new
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/php.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/php.lux
index 7312fb9de..a90a68096 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/php.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/php.lux
@@ -113,15 +113,15 @@
)))
(def: Null
- (for [@.php ffi.Null]
+ (for @.php ffi.Null
Any))
(def: Object
- (for [@.php (type (ffi.Object Any))]
+ (for @.php (type (ffi.Object Any))
Any))
(def: Function
- (for [@.php ffi.Function]
+ (for @.php ffi.Function
Any))
(def: object::new
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/python.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/python.lux
index 86affb036..f07d818d5 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/python.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/python.lux
@@ -111,23 +111,19 @@
)))
(def: None
- (for [@.python
- ffi.None]
+ (for @.python ffi.None
Any))
(def: Object
- (for [@.python
- (type (ffi.Object Any))]
+ (for @.python (type (ffi.Object Any))
Any))
(def: Function
- (for [@.python
- ffi.Function]
+ (for @.python ffi.Function
Any))
(def: Dict
- (for [@.python
- ffi.Dict]
+ (for @.python ffi.Dict
Any))
(def: object::get
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/ruby.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/ruby.lux
index 91259acc3..32c57de4e 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/ruby.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/ruby.lux
@@ -111,15 +111,15 @@
)))
(def: Nil
- (for [@.ruby ffi.Nil]
+ (for @.ruby ffi.Nil
Any))
(def: Object
- (for [@.ruby (type (ffi.Object Any))]
+ (for @.ruby (type (ffi.Object Any))
Any))
(def: Function
- (for [@.ruby ffi.Function]
+ (for @.ruby ffi.Function
Any))
(def: object::get
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/scheme.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/scheme.lux
index 659191e2f..488b39e2c 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/scheme.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/analysis/scheme.lux
@@ -113,12 +113,11 @@
)))
(def: Nil
- (for [@.scheme
- ffi.Nil]
+ (for @.scheme ffi.Nil
Any))
(def: Function
- (for [@.scheme ffi.Function]
+ (for @.scheme ffi.Function
Any))
(def: bundle::object
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua/common.lux
index 15bc133a7..40b036496 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua/common.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/extension/generation/lua/common.lux
@@ -206,7 +206,7 @@
(/.install "index" (trinary ..text//index))
(/.install "size" (unary //runtime.text//size))
... TODO: Use version below once the Lua compiler becomes self-hosted.
- ... (/.install "size" (unary (for [@.lua (!unary "utf8.len")]
+ ... (/.install "size" (unary (for @.lua (!unary "utf8.len")
... (!unary "string.len"))))
(/.install "char" (binary ..text//char))
(/.install "clip" (trinary ..text//clip))
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/runtime.lux
index 794bc1fd7..6cf9f2ff0 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/runtime.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/runtime.lux
@@ -344,7 +344,7 @@
(..char_index subject)
..lux_index)))))]
(with_vars [byte_index]
- (for [@.lua <normal>]
+ (for @.lua <normal>
(_.if ..on_rembulan?
<rembulan>
<normal>)))))
@@ -359,7 +359,7 @@
(..byte_index text)
(_.- (_.int +1))))
(_.var "string.sub")))]
- (for [@.lua <normal>]
+ (for @.lua <normal>
(_.if ..on_rembulan?
<rembulan>
<normal>))))
@@ -367,7 +367,7 @@
(runtime: (text//size subject)
(with_expansions [<rembulan> (_.return (_.apply (list subject) (_.var "string.len")))
<normal> (_.return (_.apply (list subject) (_.var "utf8.len")))]
- (for [@.lua <normal>]
+ (for @.lua <normal>
(_.if ..on_rembulan?
<rembulan>
<normal>))))
@@ -386,7 +386,7 @@
(_.if (_.= _.nil offset)
(_.statement (_.error/1 (_.string "[Lux Error] Cannot get char from text.")))
(_.return (_.apply (list text offset) (_.var "utf8.codepoint"))))))]
- (for [@.lua <normal>]
+ (for @.lua <normal>
(_.if ..on_rembulan?
<rembulan>
<normal>))))
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/runtime.lux
index 4e293bb74..13b55ccbd 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/runtime.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/runtime.lux
@@ -292,7 +292,7 @@
[(_.> ..i64::+limit) ..i64::+iteration ..i64::+cap ..i64::-limit]
[(_.< ..i64::-limit) ..i64::-iteration ..i64::-cap ..i64::+limit]
))
- (_.return (for [@.python input]
+ (_.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))))))))
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/reference.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/reference.lux
index 2ef214588..50fae65d9 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/reference.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/reference.lux
@@ -20,23 +20,30 @@
... This universe constant is for languages where one can't just turn all compiled definitions
... into the local variables of some scoping function.
(def: .public universe
- (for [ ... In the case of Lua, there is a limit of 200 locals in a function's scope.
- @.lua (not ("lua script universe"))
- ... Cannot make all definitions be local variables because of limitations with JRuby.
- @.ruby (not ("ruby script universe"))
- ... Cannot make all definitions be local variables because of limitations with PHP itself.
- @.php (not ("php script universe"))
- ... Cannot make all definitions be local variables because of limitations with Kawa.
- @.scheme (not ("scheme script universe"))]
+ (for @.lua
+ ... In the case of Lua, there is a limit of 200 locals in a function's scope.
+ (not ("lua script universe"))
+
+ @.ruby
+ ... Cannot make all definitions be local variables because of limitations with JRuby.
+ (not ("ruby script universe"))
+
+ @.php
+ ... Cannot make all definitions be local variables because of limitations with PHP itself.
+ (not ("php script universe"))
+
+ @.scheme
+ ... Cannot make all definitions be local variables because of limitations with Kawa.
+ (not ("scheme script universe"))
#0))
(def: universe_label
Text
(with_expansions [<label> (format "u" (%.nat (if ..universe 1 0)))]
- (for [@.lua <label>
- @.ruby <label>
- @.php <label>
- @.scheme <label>]
+ (for @.lua <label>
+ @.ruby <label>
+ @.php <label>
+ @.scheme <label>
"")))
(def: .public (artifact [module artifact])
diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/syntax.lux b/stdlib/source/library/lux/tool/compiler/language/lux/syntax.lux
index 0b1d000b4..971b9391f 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/syntax.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/syntax.lux
@@ -53,9 +53,9 @@
["[0]" frac]]]]])
(template: (inline: <declaration> <type> <body>)
- [(for [@.python (def: <declaration> <type> <body>)
- ... TODO: No longer skip inlining Lua after Rembulan isn't being used anymore.
- @.lua (def: <declaration> <type> <body>)]
+ [(for @.python (def: <declaration> <type> <body>)
+ ... TODO: No longer skip inlining Lua after Rembulan isn't being used anymore.
+ @.lua (def: <declaration> <type> <body>)
(template: <declaration> [<body>]))])
... TODO: Implement "lux syntax char case!" as a custom extension.
diff --git a/stdlib/source/library/lux/tool/compiler/meta/cache/module.lux b/stdlib/source/library/lux/tool/compiler/meta/cache/module.lux
index 143b3bce9..e397214b4 100644
--- a/stdlib/source/library/lux/tool/compiler/meta/cache/module.lux
+++ b/stdlib/source/library/lux/tool/compiler/meta/cache/module.lux
@@ -97,5 +97,5 @@
(|> path
(# fs read)
(# ! each (|>> [name]))))))]
- (in (dictionary.of_list text.hash (for [@.old (:as (List [Text Binary]) pairs)]
+ (in (dictionary.of_list text.hash (for @.old (:as (List [Text Binary]) pairs)
pairs)))))
diff --git a/stdlib/source/library/lux/tool/compiler/meta/io/archive.lux b/stdlib/source/library/lux/tool/compiler/meta/io/archive.lux
index a807e083c..f4125ab61 100644
--- a/stdlib/source/library/lux/tool/compiler/meta/io/archive.lux
+++ b/stdlib/source/library/lux/tool/compiler/meta/io/archive.lux
@@ -267,8 +267,8 @@
(def: (cache_parser customs)
(-> (List Custom) (Parser [(module.Module Any) Registry]))
- (case (for [@.old (:as (List (Custom Any Any Any))
- customs)]
+ (case (for @.old (:as (List (Custom Any Any Any))
+ customs)
customs)
{.#End}
(..parser $.key $.parser)