aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library
diff options
context:
space:
mode:
authorEduardo Julian2021-09-17 03:17:04 -0400
committerEduardo Julian2021-09-17 03:17:04 -0400
commitad729814254ec3fef8c75b59472bc8108ec7c4c7 (patch)
tree72e717376d80466dd568565712e88cfa1545a3a8 /stdlib/source/library
parent5fdf2b62f1f97026f76c0336a225f8b510762b46 (diff)
Handled the hiccup in Python compilation.
Diffstat (limited to '')
-rw-r--r--stdlib/source/library/lux.lux45
-rw-r--r--stdlib/source/library/lux/extension.lux38
-rw-r--r--stdlib/source/library/lux/math.lux10
-rw-r--r--stdlib/source/library/lux/tool/compiler/language/lux/syntax.lux16
4 files changed, 55 insertions, 54 deletions
diff --git a/stdlib/source/library/lux.lux b/stdlib/source/library/lux.lux
index 3cf71545b..86a1cdce7 100644
--- a/stdlib/source/library/lux.lux
+++ b/stdlib/source/library/lux.lux
@@ -4079,22 +4079,6 @@
(~+ localizations)
(~+ openings)))))
-(macro: .public (using _imports)
- (do meta_monad
- [current_module current_module_name
- imports (imports_parser #0 current_module {#End} _imports)
- .let [=imports (|> imports
- (list#each (: (-> Importation Code)
- (function (_ [module_name m_alias =refer])
- (` [(~ (text$ module_name)) (~ (text$ (..maybe#else "" m_alias)))]))))
- tuple$)
- =refers (list#each (: (-> Importation Code)
- (function (_ [module_name m_alias =refer])
- (refer_code module_name m_alias =refer)))
- imports)
- =module (` ("lux def module" (~ =imports)))]]
- (in {#Item =module =refers})))
-
(macro: .public (# tokens)
(case tokens
(^ (list struct [_ {#Symbol member}]))
@@ -4823,6 +4807,31 @@
_
(failure (..wrong_syntax_error (symbol ..for))))))
+(macro: .public (using _imports)
+ (do meta_monad
+ [current_module current_module_name
+ imports (imports_parser #0 current_module {#End} _imports)
+ .let [=imports (|> imports
+ (list#each (: (-> Importation Code)
+ (function (_ [module_name m_alias =refer])
+ (` [(~ (text$ module_name)) (~ (text$ (..maybe#else "" m_alias)))]))))
+ tuple$)
+ =refers (list#each (: (-> Importation Code)
+ (function (_ [module_name m_alias =refer])
+ (refer_code module_name m_alias =refer)))
+ imports)
+ =module (` ("lux def module" (~ =imports)))]
+ g!_ (..generated_symbol "")]
+ (in {#Item =module
+ (for [... TODO: Remove this hack once Jython is no longer being used as the Python interpreter.
+ ... Without it, I get this strange error
+ ... {library/lux/tool/compiler/language/lux/generation.no_buffer_for_saving_code}
+ ... Artifact ID: 0
+ ... Which only ever happens for the Python compiler.
+ "Python" (list& (` ("lux def" (~ g!_) [] #0))
+ =refers)]
+ =refers)})))
+
(def: (embedded_expansions code)
(-> Code (Meta [(List [Code Code]) Code]))
(case code
@@ -4977,7 +4986,9 @@
(def: (methodP tokens)
(-> (List Code) (Maybe [(List Code) [Text Code]]))
(case tokens
- (^ (list& [_ {#Form (list [_ {#Text "lux type check"}] type [_ {#Symbol ["" name]}])}]
+ (^ (list& [_ {#Form (list [_ {#Text "lux type check"}]
+ type
+ [_ {#Symbol ["" name]}])}]
tokens'))
{#Some [tokens' [name type]]}
diff --git a/stdlib/source/library/lux/extension.lux b/stdlib/source/library/lux/extension.lux
index f19fe9594..cabab0a8f 100644
--- a/stdlib/source/library/lux/extension.lux
+++ b/stdlib/source/library/lux/extension.lux
@@ -1,23 +1,23 @@
(.using
- [library
- [lux "*"
- [abstract
- ["[0]" monad]]
- [control
- ["<>" parser ("[1]#[0]" monad)
- ["<c>" code {"+" Parser}]
- ["<a>" analysis]
- ["<s>" synthesis]]]
- [data
- ["[0]" product]
- [collection
- ["[0]" list ("[1]#[0]" functor)]]]
- [macro {"+" with_symbols}
- ["[0]" code]
- [syntax {"+" syntax:}]]
- [tool
- [compiler
- ["[0]" phase]]]]])
+ [library
+ [lux "*"
+ [abstract
+ ["[0]" monad]]
+ [control
+ ["<>" parser ("[1]#[0]" monad)
+ ["<c>" code {"+" Parser}]
+ ["<a>" analysis]
+ ["<s>" synthesis]]]
+ [data
+ ["[0]" product]
+ [collection
+ ["[0]" list ("[1]#[0]" functor)]]]
+ [macro {"+" with_symbols}
+ ["[0]" code]
+ [syntax {"+" syntax:}]]
+ [tool
+ [compiler
+ ["[0]" phase]]]]])
(type: Declaration
(Record
diff --git a/stdlib/source/library/lux/math.lux b/stdlib/source/library/lux/math.lux
index 27f3a9f76..2c095da17 100644
--- a/stdlib/source/library/lux/math.lux
+++ b/stdlib/source/library/lux/math.lux
@@ -146,9 +146,15 @@
(-> Frac Frac Frac)
(:as Frac ("python object do" "pow" ("python import" "math") subject param)))
- (def: .public root/3
+ (def: .public (root/3 it)
(-> Frac Frac)
- (..pow ("lux f64 /" +3.0 +1.0))))
+ (if ("lux f64 <" +0.0 it)
+ (|> it
+ ("lux f64 *" -1.0)
+ (..pow ("lux f64 /" +3.0 +1.0))
+ ("lux f64 *" -1.0))
+ (|> it
+ (..pow ("lux f64 /" +3.0 +1.0))))))
@.lua
(as_is (template [<name> <method>]
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 f9e6a723a..9ca68013e 100644
--- a/stdlib/source/library/lux/tool/compiler/language/lux/syntax.lux
+++ b/stdlib/source/library/lux/tool/compiler/language/lux/syntax.lux
@@ -244,22 +244,6 @@
[tuple_parser ..close_tuple .#Tuple]
)
-(inline: (record_parser parse where offset source_code)
- (-> (Parser Code) Location Offset Text
- (Either [Source Text] [Source Code]))
- (loop [source (: Source [(!forward 1 where) offset source_code])
- stack (: (List [Code Code]) {.#End})]
- (case (parse source)
- {.#Right [sourceF field]}
- (!letE [sourceFV value] (parse sourceF)
- (again sourceFV {.#Item [field value] stack}))
-
- {.#Left [source' error]}
- (if (same? ..close_variant error)
- {.#Right [source'
- [where {.#Record (list.reversed stack)}]]}
- {.#Left [source' error]}))))
-
(template: (!guarantee_no_new_lines where offset source_code content body)
[(case ("lux text index" 0 (static text.new_line) content)
{.#None}