aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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
-rw-r--r--stdlib/source/test/lux.lux128
-rw-r--r--stdlib/source/test/lux/extension.lux94
-rw-r--r--stdlib/source/test/lux/math.lux46
7 files changed, 192 insertions, 185 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}
diff --git a/stdlib/source/test/lux.lux b/stdlib/source/test/lux.lux
index f1ae8f0de..84353e082 100644
--- a/stdlib/source/test/lux.lux
+++ b/stdlib/source/test/lux.lux
@@ -3,70 +3,70 @@
(.as_is))
<target> <target>']
(.using
- [library
- ["/" lux "*"
- [program {"+" program:}]
- ["_" test {"+" Test}]
- ["@" target]
- [abstract
- [monad {"+" do}]]
- [control
- ["[0]" io]
- ["[0]" maybe ("[1]#[0]" functor)]
- [concurrency
- ["[0]" atom {"+" Atom}]]
- [parser
- ["<[0]>" code]]]
- [data
- ["[0]" product]
- ["[0]" bit ("[1]#[0]" equivalence)]
- ["[0]" text ("[1]#[0]" equivalence)
- ["%" format {"+" format}]]
- [collection
- ["[0]" list ("[1]#[0]" functor)]
- ["[0]" set {"+" Set} ("[1]#[0]" equivalence)]
- [dictionary
- ["[0]" plist]]]]
- ["[0]" macro
- [syntax {"+" syntax:}]
- ["[0]" code ("[1]#[0]" equivalence)]
- ["[0]" template]]
- ["[0]" math
- ["[0]" random ("[1]#[0]" functor)]
- [number
- [i8 {"+"}]
- [i16 {"+"}]
- ["n" nat]
- ["i" int]
- ["r" rev]
- ["f" frac]
- ["[0]" i64]]]
- ["[0]" meta
- ["[0]" location ("[1]#[0]" equivalence)]]]]
- ... TODO: Must have 100% coverage on tests.
- ["[0]" / "_"
- ["[1][0]" abstract]
- ["[1][0]" control]
- ["[1][0]" data]
- ["[1][0]" debug]
- ["[1][0]" documentation]
- ["[1][0]" locale]
- ["[1][0]" macro
- ["[1]/[0]" code]]
- ["[1][0]" math]
- ["[1][0]" meta]
- ["[1][0]" program]
- ["[1][0]" static]
- ["[1][0]" target]
- ["[1][0]" test]
- ["[1][0]" time]
- ... ["[1][0]" tool] ... TODO: Update & expand tests for this
- ["[1][0]" type]
- ["[1][0]" world]
- ["[1][0]" ffi]
- ["[1][0]" extension]
- ["[1][0]" target "_"
- <target>]]))
+ [library
+ ["/" lux "*"
+ [program {"+" program:}]
+ ["_" test {"+" Test}]
+ ["@" target]
+ [abstract
+ [monad {"+" do}]]
+ [control
+ ["[0]" io]
+ ["[0]" maybe ("[1]#[0]" functor)]
+ [concurrency
+ ["[0]" atom {"+" Atom}]]
+ [parser
+ ["<[0]>" code]]]
+ [data
+ ["[0]" product]
+ ["[0]" bit ("[1]#[0]" equivalence)]
+ ["[0]" text ("[1]#[0]" equivalence)
+ ["%" format {"+" format}]]
+ [collection
+ ["[0]" list ("[1]#[0]" functor)]
+ ["[0]" set {"+" Set} ("[1]#[0]" equivalence)]
+ [dictionary
+ ["[0]" plist]]]]
+ ["[0]" macro
+ [syntax {"+" syntax:}]
+ ["[0]" code ("[1]#[0]" equivalence)]
+ ["[0]" template]]
+ ["[0]" math
+ ["[0]" random ("[1]#[0]" functor)]
+ [number
+ [i8 {"+"}]
+ [i16 {"+"}]
+ ["n" nat]
+ ["i" int]
+ ["r" rev]
+ ["f" frac]
+ ["[0]" i64]]]
+ ["[0]" meta
+ ["[0]" location ("[1]#[0]" equivalence)]]]]
+ ... TODO: Must have 100% coverage on tests.
+ ["[0]" / "_"
+ ["[1][0]" abstract]
+ ["[1][0]" control]
+ ["[1][0]" data]
+ ["[1][0]" debug]
+ ["[1][0]" documentation]
+ ["[1][0]" locale]
+ ["[1][0]" macro
+ ["[1]/[0]" code]]
+ ["[1][0]" math]
+ ["[1][0]" meta]
+ ["[1][0]" program]
+ ["[1][0]" static]
+ ["[1][0]" target]
+ ["[1][0]" test]
+ ["[1][0]" time]
+ ... ["[1][0]" tool] ... TODO: Update & expand tests for this
+ ["[1][0]" type]
+ ["[1][0]" world]
+ ["[1][0]" ffi]
+ ["[1][0]" extension]
+ ["[1][0]" target "_"
+ <target>]]))
... TODO: Get rid of this ASAP
(template: (!bundle body)
diff --git a/stdlib/source/test/lux/extension.lux b/stdlib/source/test/lux/extension.lux
index 27ff33027..63f3b0d5d 100644
--- a/stdlib/source/test/lux/extension.lux
+++ b/stdlib/source/test/lux/extension.lux
@@ -1,48 +1,48 @@
(.using
- [library
- [lux "*"
- ["[0]" debug]
- ["@" target
- ["[0]" jvm]
- ["[0]" js]
- ["[0]" python]
- ["[0]" lua]
- ["[0]" ruby]
- ["[0]" php]
- ["[0]" scheme]]
- [abstract
- ["[0]" monad {"+" do}]]
- [control
- ["[0]" try]
- ["<>" parser
- ["<[0]>" code]
- ["<[0]>" analysis]
- ["<[0]>" synthesis]]]
- [data
- ["[0]" product]
- ["[0]" text ("[1]#[0]" equivalence)
- ["%" format {"+" format}]]
- [collection
- ["[0]" sequence]
- ["[0]" list ("[1]#[0]" functor)]]]
- [math
- ["[0]" random]
- [number
- ["n" nat]]]
- [tool
- [compiler
- ["[0]" phase]
- [language
- [lux
- ["[0]" analysis]
- ["[0]" synthesis]
- ["[0]" directive]
- [phase
- [analysis
- ["[0]" type]]]]]]]
- ["_" test {"+" Test}]]]
- [\\library
- ["[0]" / {"+" analysis: synthesis: generation: directive:}]])
+ [library
+ [lux "*"
+ ["[0]" debug]
+ ["@" target
+ ["[0]" jvm]
+ ["[0]" js]
+ ["[0]" python]
+ ["[0]" lua]
+ ["[0]" ruby]
+ ["[0]" php]
+ ["[0]" scheme]]
+ [abstract
+ ["[0]" monad {"+" do}]]
+ [control
+ ["[0]" try]
+ ["<>" parser
+ ["<[0]>" code]
+ ["<[0]>" analysis]
+ ["<[0]>" synthesis]]]
+ [data
+ ["[0]" product]
+ ["[0]" text ("[1]#[0]" equivalence)
+ ["%" format {"+" format}]]
+ [collection
+ ["[0]" sequence]
+ ["[0]" list ("[1]#[0]" functor)]]]
+ [math
+ ["[0]" random]
+ [number
+ ["n" nat]]]
+ [tool
+ [compiler
+ ["[0]" phase]
+ [language
+ [lux
+ ["[0]" analysis]
+ ["[0]" synthesis]
+ ["[0]" directive]
+ [phase
+ [analysis
+ ["[0]" type]]]]]]]
+ ["_" test {"+" Test}]]]
+ [\\library
+ ["[0]" / {"+" analysis: synthesis: generation: directive:}]])
(def: my_analysis "my analysis")
(def: my_synthesis "my synthesis")
@@ -55,6 +55,12 @@
(as_is)]
(as_is
+ (for [@.python
+ ... TODO: Remove this hack once Jython is no longer being used as the Python interpreter.
+ (analysis: ("dummy dum dum" self phase archive [])
+ (undefined))]
+ (as_is))
+
... Analysis
(analysis: (..my_analysis self phase archive [pass_through <code>.any])
(phase archive pass_through))
diff --git a/stdlib/source/test/lux/math.lux b/stdlib/source/test/lux/math.lux
index 7d30f864d..aeadbf093 100644
--- a/stdlib/source/test/lux/math.lux
+++ b/stdlib/source/test/lux/math.lux
@@ -1,27 +1,27 @@
(.using
- [library
- [lux "*"
- ["_" test {"+" Test}]
- [abstract
- [monad {"+" do}]]
- [macro
- ["[0]" template]]
- [math
- ["[0]" random {"+" Random}]
- [number
- ["n" nat]
- ["i" int]
- ["f" frac]]]]]
- [\\library
- ["[0]" /]]
- ["[0]" / "_"
- ["[1][0]" infix]
- ["[1][0]" modulus]
- ["[1][0]" modular]
- ["[1][0]" number]
- ["[1][0]" logic "_"
- ["[1]/[0]" continuous]
- ["[1]/[0]" fuzzy]]])
+ [library
+ [lux "*"
+ ["_" test {"+" Test}]
+ [abstract
+ [monad {"+" do}]]
+ [macro
+ ["[0]" template]]
+ [math
+ ["[0]" random {"+" Random}]
+ [number
+ ["n" nat]
+ ["i" int]
+ ["f" frac]]]]]
+ [\\library
+ ["[0]" /]]
+ ["[0]" / "_"
+ ["[1][0]" infix]
+ ["[1][0]" modulus]
+ ["[1][0]" modular]
+ ["[1][0]" number]
+ ["[1][0]" logic "_"
+ ["[1]/[0]" continuous]
+ ["[1]/[0]" fuzzy]]])
(def: margin_of_error
+0.0000001)