diff options
22 files changed, 291 insertions, 286 deletions
diff --git a/lux-lua/project.clj b/lux-lua/project.clj index 212304338..559f57aab 100644 --- a/lux-lua/project.clj +++ b/lux-lua/project.clj @@ -20,7 +20,7 @@ ["snapshots" {:url ~sonatype-snapshots :creds :gpg}]] :plugins [[com.github.luxlang/lein-luxc ~version]] - :dependencies [[com.github.luxlang/luxc-jvm ~version] + :dependencies [[com.github.luxlang/lux-bootstrapper ~version] [com.github.luxlang/stdlib ~version] [net.sandius.rembulan/rembulan-runtime "0.1-SNAPSHOT"] [net.sandius.rembulan/rembulan-stdlib "0.1-SNAPSHOT"] diff --git a/lux-lua/source/program.lux b/lux-lua/source/program.lux index 5adcb43d9..962da273f 100644 --- a/lux-lua/source/program.lux +++ b/lux-lua/source/program.lux @@ -561,12 +561,12 @@ [[state_context executor] (: (Host _.Expression _.Statement) (implementation - (def: (evaluate! context code) + (def: (evaluate context code) (run! (_.return code))) - (def: execute! run!) + (def: execute run!) - (def: (define! context custom input) + (def: (define context custom input) (let [global (maybe.else (reference.artifact context) custom) @global (_.var global)] diff --git a/lux-python/source/program.lux b/lux-python/source/program.lux index ccf478053..5383c1b0d 100644 --- a/lux-python/source/program.lux +++ b/lux-python/source/program.lux @@ -290,9 +290,9 @@ output)))] (: (Host (_.Expression Any) (_.Statement Any)) (implementation - (def: evaluate! evaluate!) - (def: execute! execute!) - (def: (define! context custom input) + (def: evaluate evaluate!) + (def: execute execute!) + (def: (define context custom input) (let [global (maybe.else (reference.artifact context) custom) @global (_.var global)] diff --git a/lux-ruby/project.clj b/lux-ruby/project.clj index 88b172b40..36430ec9a 100644 --- a/lux-ruby/project.clj +++ b/lux-ruby/project.clj @@ -20,7 +20,7 @@ ["snapshots" {:url ~sonatype-snapshots :creds :gpg}]] :plugins [[com.github.luxlang/lein-luxc ~version]] - :dependencies [[com.github.luxlang/luxc-jvm ~version] + :dependencies [[com.github.luxlang/lux-bootstrapper ~version] [com.github.luxlang/stdlib ~version] [org.jruby/jruby-complete "9.2.15.0"]] diff --git a/lux-ruby/source/program.lux b/lux-ruby/source/program.lux index f2e429d15..ee569e392 100644 --- a/lux-ruby/source/program.lux +++ b/lux-ruby/source/program.lux @@ -28,8 +28,7 @@ ["[0]" list]]] ["[0]" macro [syntax {"+" syntax:}] - ["[0]" template] - ["[0]" code]] + ["[0]" template]] [math [number {"+" hex} ["n" nat] @@ -132,14 +131,6 @@ ["[1]::[0]" (getValue [] java/lang/Object)]) -(syntax: (method_inputs [input_classes (<code>.tuple (<>.some <code>.any))]) - (monad.each meta.monad - (function (_ class) - (do meta.monad - [var (macro.symbol "input")] - (in (code.record (list [var class]))))) - input_classes)) - (import: org/jruby/runtime/JavaSites$CheckedSites) (import: org/jruby/runtime/builtin/Variable) (import: org/jruby/runtime/builtin/InstanceVariables) @@ -609,12 +600,12 @@ output)))))] (: (Host _.Expression _.Statement) (implementation - (def: (evaluate! context code) + (def: (evaluate context code) (run! code)) - (def: execute! run!) + (def: execute run!) - (def: (define! context custom input) + (def: (define context custom input) (let [global (maybe.else (reference.artifact context) custom) @global (_.global global)] diff --git a/stdlib/source/library/lux.lux b/stdlib/source/library/lux.lux index a474ac1a4..3cf71545b 100644 --- a/stdlib/source/library/lux.lux +++ b/stdlib/source/library/lux.lux @@ -823,18 +823,52 @@ (failure "Wrong syntax for $'")} tokens)) +... (def:'' .private (list#each f xs) +... {#UnivQ {#End} +... {#UnivQ {#End} +... {#Function {#Function {#Parameter 3} {#Parameter 1}} +... {#Function ($' List {#Parameter 3}) +... ($' List {#Parameter 1})}}}} +... ({{#End} +... {#End} + +... {#Item x xs'} +... {#Item (f x) (list#each f xs')}} +... xs)) + +(def:'' .private (list#mix f init xs) + ... (All (_ a b) (-> (-> b a a) a (List b) a)) + {#UnivQ {#End} {#UnivQ {#End} {#Function {#Function {#Parameter 1} + {#Function {#Parameter 3} + {#Parameter 3}}} + {#Function {#Parameter 3} + {#Function ($' List {#Parameter 1}) + {#Parameter 3}}}}}} + ({{#End} + init + + {#Item x xs'} + (list#mix f (f x init) xs')} + xs)) + +(def:'' .private (list#reversed list) + {#UnivQ {#End} + {#Function ($' List {#Parameter 1}) ($' List {#Parameter 1})}} + (list#mix ("lux type check" {#UnivQ {#End} + {#Function {#Parameter 1} {#Function ($' List {#Parameter 1}) ($' List {#Parameter 1})}}} + (function'' [head tail] {#Item head tail})) + {#End} + list)) + (def:'' .private (list#each f xs) {#UnivQ {#End} {#UnivQ {#End} {#Function {#Function {#Parameter 3} {#Parameter 1}} {#Function ($' List {#Parameter 3}) ($' List {#Parameter 1})}}}} - ({{#End} - {#End} - - {#Item x xs'} - {#Item (f x) (list#each f xs')}} - xs)) + (list#mix (function'' [head tail] {#Item (f head) tail}) + {#End} + (list#reversed xs))) (def:'' .private Replacement_Environment Type @@ -897,21 +931,6 @@ ("lux type as" Int param) ("lux type as" Int subject)))) -(def:'' .private (list#mix f init xs) - ... (All (_ a b) (-> (-> b a a) a (List b) a)) - {#UnivQ {#End} {#UnivQ {#End} {#Function {#Function {#Parameter 1} - {#Function {#Parameter 3} - {#Parameter 3}}} - {#Function {#Parameter 3} - {#Function ($' List {#Parameter 1}) - {#Parameter 3}}}}}} - ({{#End} - init - - {#Item x xs'} - (list#mix f (f x init) xs')} - xs)) - (def:'' .private (list#size list) {#UnivQ {#End} {#Function ($' List {#Parameter 1}) Nat}} @@ -1132,15 +1151,6 @@ {#Left "Wrong syntax for Ex"}} tokens)) -(def:'' .private (list#reversed list) - (All (_ a) - {#Function ($' List a) ($' List a)}) - (list#mix ("lux type check" (All (_ a) - {#Function a {#Function ($' List a) ($' List a)}}) - (function'' [head tail] {#Item head tail})) - {#End} - list)) - (macro:' .public (-> tokens) ({{#Item output inputs} (in_meta {#Item (list#mix ("lux type check" {#Function Code {#Function Code Code}} @@ -4878,8 +4888,8 @@ (in (` [(~ g!meta) {<tag> (~ (untemplated_list =elems))}])))))] [.#Form untemplated_form] - [.#Tuple untemplated_tuple] [.#Variant untemplated_variant] + [.#Tuple untemplated_tuple] ) (def: (untemplated_pattern pattern) @@ -4890,12 +4900,12 @@ (^template [<tag> <gen>] [[_ {<tag> value}] (in (` [(~ g!meta) {<tag> (~ (<gen> value))}]))]) - ([.#Bit bit$] - [.#Nat nat$] - [.#Int int$] - [.#Rev rev$] - [.#Frac frac$] - [.#Text text$] + ([.#Bit bit$] + [.#Nat nat$] + [.#Int int$] + [.#Rev rev$] + [.#Frac frac$] + [.#Text text$] [.#Symbol name$]) [_ {#Form {#Item [[_ {#Symbol ["" "~"]}] {#Item [unquoted {#End}]}]}}] @@ -4945,7 +4955,7 @@ (list localT (` (..as_is (~ valueT)))))) (list#mix list#composite (list))))] (~ bodyT))))) - + {#None} (..failure ":let requires an even number of parts")) @@ -4981,7 +4991,7 @@ {#Some methods} (in (list (` (..Tuple (~+ (list#each product#right methods)))) (tuple$ (list#each (|>> product#left text$) methods)))) - + {#None} (failure "Wrong syntax for Interface")))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/case.lux index e4d3f24eb..3afa582f0 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/case.lux @@ -65,7 +65,7 @@ (in (list#mix (function (_ side source) (.let [method (.case side (^template [<side> <accessor>] - [(<side> lefts) + [{<side> lefts} (<accessor> (_.int (.int lefts)))]) ([.#Left //runtime.tuple//left] [.#Right //runtime.tuple//right]))] @@ -132,11 +132,12 @@ (def: fail! _.break) -(template [<name> <flag> <prep>] +(template [<name> <flag>] [(def: (<name> simple? idx) (-> Bit Nat Statement) ($_ _.then - (_.set (list @temp) (|> idx <prep> .int _.int (//runtime.sum//get ..peek <flag>))) + (_.set (list @temp) (//runtime.sum//get ..peek <flag> + (|> idx .int _.int))) (.if simple? (_.when (_.= _.nil @temp) fail!) @@ -144,8 +145,8 @@ fail! (..push! @temp)))))] - [left_choice _.nil (<|)] - [right_choice (_.string "") ++] + [left_choice _.nil] + [right_choice //runtime.unit] ) (def: (alternation pre! post!) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/function.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/function.lux index 2efddb21e..5b5d0be04 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/function.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/function.lux @@ -1,6 +1,6 @@ (.using [library - [lux {"-" Tuple Variant function} + [lux {"-" Tuple Variant Label function} [abstract ["[0]" monad {"+" do}]] [control diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/loop.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/loop.lux index f620e0445..2bc8a7868 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/loop.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/loop.lux @@ -1,6 +1,6 @@ (.using [library - [lux {"-" Scope} + [lux {"-" Label Scope} [abstract ["[0]" monad {"+" do}]] [data diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/reference.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/reference.lux index 55cd8de06..f3ff385ae 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/reference.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/reference.lux @@ -9,5 +9,5 @@ (implementation: .public system (System Expression) - (def: constant _.var) - (def: variable _.var)) + (def: constant' _.var) + (def: variable' _.var)) 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 6c584f9b2..087f3e146 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 @@ -1,6 +1,6 @@ (.using [library - [lux {"-" Location} + [lux {"-" Label Location} ["[0]" meta] [abstract ["[0]" monad {"+" do}]] @@ -82,21 +82,21 @@ (flag last?) value)) -(def: .public none - Literal - (..variant 0 #0 ..unit)) - -(def: .public some - (-> Expression Literal) - (..variant 1 #1)) - (def: .public left (-> Expression Literal) (..variant 0 #0)) (def: .public right (-> Expression Literal) - (..variant 1 #1)) + (..variant 0 #1)) + +(def: .public none + Literal + (..left ..unit)) + +(def: .public some + (-> Expression Literal) + ..right) (def: (feature name definition) (-> Var (-> Var Statement) Statement) @@ -198,30 +198,34 @@ (_.var "table.move")))) ))))) -(runtime: (sum//get sum wants_last wanted_tag) - (let [no_match! (_.return _.nil) - sum_tag (_.the ..variant_tag_field sum) - sum_flag (_.the ..variant_flag_field sum) - sum_value (_.the ..variant_value_field sum) - is_last? (_.= ..unit sum_flag) - extact_match! (_.return sum_value) - test_recursion! (_.if is_last? - ... Must recurse. - ($_ _.then - (_.set (list wanted_tag) (_.- sum_tag wanted_tag)) - (_.set (list sum) sum_value)) - no_match!) - extrac_sub_variant! (_.return (variant' (_.- wanted_tag sum_tag) sum_flag sum_value))] +(runtime: (sum//get sum expected##right? expected##lefts) + (let [mismatch! (_.return _.nil) + actual##lefts (_.the ..variant_tag_field sum) + actual##right? (_.the ..variant_flag_field sum) + actual##value (_.the ..variant_value_field sum) + recur! ($_ _.then + (_.set (list expected##lefts) (|> expected##lefts + (_.- actual##lefts) + (_.- (_.int +1)))) + (_.set (list sum) actual##value))] (<| (_.while (_.bool true)) - (_.cond (list [(_.= sum_tag wanted_tag) - (_.if (_.= wants_last sum_flag) - extact_match! - test_recursion!)] - [(_.< wanted_tag sum_tag) - test_recursion!] - [(_.= ..unit wants_last) - extrac_sub_variant!]) - no_match!)))) + (_.cond (list [(_.= expected##lefts actual##lefts) + (_.if (_.= expected##right? actual##right?) + (_.return actual##value) + mismatch!)] + + [(_.< expected##lefts actual##lefts) + (_.if (_.= ..unit actual##right?) + recur! + mismatch!)] + + [(_.= ..unit expected##right?) + (_.return (variant' (|> actual##lefts + (_.- expected##lefts) + (_.- (_.int +1))) + actual##right? + actual##value))]) + mismatch!)))) (def: runtime//adt Statement diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/structure.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/structure.lux index f42206a3c..3c491e788 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/structure.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/lua/structure.lux @@ -1,18 +1,18 @@ (.using - [library - [lux {"-" Tuple Variant} - [abstract - ["[0]" monad {"+" do}]] - [target - ["_" lua {"+" Expression}]]]] - ["[0]" // "_" - ["[1][0]" runtime {"+" Operation Phase Generator}] - ["[1][0]" primitive] - ["///[1]" //// "_" - [analysis {"+" Variant Tuple}] - ["[1][0]" synthesis {"+" Synthesis}] - ["//[1]" /// "_" - ["[1][0]" phase ("[1]#[0]" monad)]]]]) + [library + [lux {"-" Tuple Variant} + [abstract + ["[0]" monad {"+" do}]] + [target + ["_" lua {"+" Expression}]]]] + ["[0]" // "_" + ["[1][0]" runtime {"+" Operation Phase Generator}] + ["[1][0]" primitive] + ["///[1]" //// "_" + [analysis {"+" Variant Tuple}] + ["[1][0]" synthesis {"+" Synthesis}] + ["//[1]" /// "_" + ["[1][0]" phase ("[1]#[0]" monad)]]]]) (def: .public (tuple generate archive elemsS+) (Generator (Tuple Synthesis)) @@ -30,8 +30,5 @@ (def: .public (variant generate archive [lefts right? valueS]) (Generator (Variant Synthesis)) - (let [tag (if right? - (++ lefts) - lefts)] - (///////phase#each (//runtime.variant tag right?) - (generate archive valueS)))) + (///////phase#each (//runtime.variant lefts right?) + (generate archive valueS))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/case.lux index c2b153439..4be219e6f 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/case.lux @@ -91,7 +91,7 @@ (in (list#mix (function (_ side source) (.let [method (.case side (^template [<side> <accessor>] - [(<side> lefts) + [{<side> lefts} (<accessor> (_.int (.int lefts)))]) ([.#Left //runtime.tuple::left] [.#Right //runtime.tuple::right]))] @@ -134,11 +134,12 @@ (-> Nat (Statement Any)) (_.delete (_.slice_from (_.int (i.* -1 (.int pops))) @cursor))) -(template [<name> <flag> <prep>] +(template [<name> <flag>] [(def: (<name> simple? idx) (-> Bit Nat (Statement Any)) ($_ _.then - (_.set (list @temp) (|> idx <prep> .int _.int (//runtime.sum::get ..peek <flag>))) + (_.set (list @temp) (//runtime.sum::get ..peek <flag> + (|> idx .int _.int))) (.if simple? (_.when (_.= _.none @temp) fail_pm!) @@ -147,8 +148,8 @@ (..push! @temp)) )))] - [left_choice _.none (<|)] - [right_choice (_.string "") ++] + [left_choice _.none] + [right_choice //runtime.unit] ) (def: (with_looping in_closure? g!once body!) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/reference.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/reference.lux index 82d999675..10dcfeec9 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/reference.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/reference.lux @@ -9,5 +9,5 @@ (implementation: .public system (System (Expression Any)) - (def: constant _.var) - (def: variable _.var)) + (def: constant' _.var) + (def: variable' _.var)) 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 51127770a..1b89fd694 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 @@ -1,44 +1,44 @@ (.using - [library - [lux {"-" ++} - ["[0]" meta] - [abstract - ["[0]" monad {"+" do}]] - [control - ["[0]" function] - ["<>" parser - ["<[0]>" code]]] - [data - ["[0]" product] - ["[0]" text ("[1]#[0]" hash) - ["%" format {"+" format}] - [encoding - ["[0]" utf8]]] - [collection - ["[0]" list ("[1]#[0]" functor)] - ["[0]" sequence]]] - ["[0]" macro - [syntax {"+" syntax:}] - ["[0]" code]] - [math - [number {"+" hex} - ["f" frac] - ["[0]" i64]]] - ["@" target - ["_" python {"+" Expression SVar Computation Literal Statement}]]]] - ["[0]" /// "_" - ["[1][0]" reference] - ["//[1]" /// "_" - ["$" version] - ["[1][0]" synthesis {"+" Synthesis}] - ["[1][0]" generation] - ["//[1]" /// - ["[1][0]" phase] - [reference - [variable {"+" Register}]] - [meta - [archive {"+" Output Archive} - ["[0]" artifact {"+" Registry}]]]]]]) + [library + [lux {"-" ++} + ["[0]" meta] + [abstract + ["[0]" monad {"+" do}]] + [control + ["[0]" function] + ["<>" parser + ["<[0]>" code]]] + [data + ["[0]" product] + ["[0]" text ("[1]#[0]" hash) + ["%" format {"+" format}] + [encoding + ["[0]" utf8]]] + [collection + ["[0]" list ("[1]#[0]" functor)] + ["[0]" sequence]]] + ["[0]" macro + [syntax {"+" syntax:}] + ["[0]" code]] + [math + [number {"+" hex} + ["f" frac] + ["[0]" i64]]] + ["@" target + ["_" python {"+" Expression SVar Computation Literal Statement}]]]] + ["[0]" /// "_" + ["[1][0]" reference] + ["//[1]" /// "_" + ["$" version] + ["[1][0]" synthesis {"+" Synthesis}] + ["[1][0]" generation] + ["//[1]" /// + ["[1][0]" phase] + [reference + [variable {"+" Register}]] + [meta + [archive {"+" Output Archive} + ["[0]" artifact {"+" Registry}]]]]]]) (template [<name> <base>] [(type: .public <name> @@ -62,8 +62,7 @@ (def: prefix "LuxRuntime") -(def: .public - unit +(def: .public unit (_.unicode /////synthesis.unit)) (def: (flag value) @@ -82,21 +81,21 @@ (flag last?) value)) -(def: .public none - Literal - (..variant 0 #0 unit)) - -(def: .public some - (-> (Expression Any) Literal) - (..variant 1 #1)) - (def: .public left (-> (Expression Any) Literal) (..variant 0 #0)) (def: .public right (-> (Expression Any) Literal) - (..variant 1 #1)) + (..variant 0 #1)) + +(def: .public none + Literal + (..left ..unit)) + +(def: .public some + (-> (Expression Any) Literal) + ..right) (def: (runtime_name name) (-> Text SVar) @@ -236,31 +235,34 @@ (_.return (_.slice_from right_index tuple)))) {.#None})))) -(runtime: (sum::get sum wantsLast wantedTag) - (let [no_match! (_.return _.none) - sum_tag (_.item (_.int +0) sum) - sum_flag (_.item (_.int +1) sum) - sum_value (_.item (_.int +2) sum) - is_last? (_.= ..unit sum_flag) - test_recursion! (_.if is_last? - ... Must recurse. - ($_ _.then - (_.set (list wantedTag) (_.- sum_tag wantedTag)) - (_.set (list sum) sum_value)) - no_match!)] +(runtime: (sum::get sum expected##right? expected##lefts) + (let [mismatch! (_.return _.none) + actual##lefts (_.item (_.int +0) sum) + actual##right? (_.item (_.int +1) sum) + actual##value (_.item (_.int +2) sum) + recur! ($_ _.then + (_.set (list expected##lefts) (|> expected##lefts + (_.- actual##lefts) + (_.- (_.int +1)))) + (_.set (list sum) actual##value))] (_.while (_.bool true) - (_.cond (list [(_.= wantedTag sum_tag) - (_.if (_.= wantsLast sum_flag) - (_.return sum_value) - test_recursion!)] - - [(_.< wantedTag sum_tag) - test_recursion!] - - [(_.= ..unit wantsLast) - (_.return (variant' (_.- wantedTag sum_tag) sum_flag sum_value))]) - - no_match!) + (_.cond (list [(_.= expected##lefts actual##lefts) + (_.if (_.= expected##right? actual##right?) + (_.return actual##value) + mismatch!)] + + [(_.< expected##lefts actual##lefts) + (_.if (_.= ..unit actual##right?) + recur! + mismatch!)] + + [(_.= ..unit expected##right?) + (_.return (variant' (|> actual##lefts + (_.- expected##lefts) + (_.- (_.int +1))) + actual##right? + actual##value))]) + mismatch!) {.#None}))) (def: runtime::adt diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/structure.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/structure.lux index b4bb7afe1..0b3183166 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/structure.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/python/structure.lux @@ -1,18 +1,18 @@ (.using - [library - [lux {"-" Variant Tuple} - [abstract - ["[0]" monad {"+" do}]] - [target - ["_" python {"+" Expression}]]]] - ["[0]" // "_" - ["[1][0]" runtime {"+" Operation Phase Generator}] - ["[1][0]" primitive] - ["///[1]" //// "_" - [analysis {"+" Variant Tuple}] - ["[1][0]" synthesis {"+" Synthesis}] - ["//[1]" /// "_" - ["[1][0]" phase ("[1]#[0]" monad)]]]]) + [library + [lux {"-" Variant Tuple} + [abstract + ["[0]" monad {"+" do}]] + [target + ["_" python {"+" Expression}]]]] + ["[0]" // "_" + ["[1][0]" runtime {"+" Operation Phase Generator}] + ["[1][0]" primitive] + ["///[1]" //// "_" + [analysis {"+" Variant Tuple}] + ["[1][0]" synthesis {"+" Synthesis}] + ["//[1]" /// "_" + ["[1][0]" phase ("[1]#[0]" monad)]]]]) (def: .public (tuple generate archive elemsS+) (Generator (Tuple Synthesis)) @@ -30,8 +30,5 @@ (def: .public (variant generate archive [lefts right? valueS]) (Generator (Variant Synthesis)) - (let [tag (if right? - (++ lefts) - lefts)] - (///////phase#each (//runtime.variant tag right?) - (generate archive valueS)))) + (///////phase#each (//runtime.variant lefts right?) + (generate archive valueS))) 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 00a31a308..34ecfcf7a 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 @@ -47,15 +47,15 @@ (type: .public (System expression) (Interface (: (-> Text expression) - constant) + constant') (: (-> Text expression) - variable))) + variable'))) (def: .public (constant system archive name) (All (_ anchor expression directive) - (-> (System expression) Archive Name + (-> (System expression) Archive Symbol (////generation.Operation anchor expression directive expression))) - (phase#each (|>> ..artifact (# system constant)) + (phase#each (|>> ..artifact (# system constant')) (////generation.remember archive name))) (template [<sigil> <name>] @@ -63,7 +63,7 @@ (All (_ expression) (-> (System expression) (-> Register expression))) - (|>> %.nat (format <sigil>) (# system variable)))] + (|>> %.nat (format <sigil>) (# system variable')))] ["f" foreign] ["l" local] diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/case.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/case.lux index 1be61b59b..499bc7c36 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/case.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/case.lux @@ -138,11 +138,12 @@ (_.int (.int pops))) @cursor))) -(template [<name> <flag> <prep>] +(template [<name> <flag>] [(def: (<name> simple? idx) (-> Bit Nat Statement) ($_ _.then - (_.set (list @temp) (|> idx <prep> .int _.int (//runtime.sum//get ..peek <flag>))) + (_.set (list @temp) (//runtime.sum//get ..peek <flag> + (|> idx .int _.int))) (.if simple? (_.when (_.= _.nil @temp) fail!) @@ -150,8 +151,8 @@ fail! (..push! @temp)))))] - [left_choice _.nil (<|)] - [right_choice (_.string "") ++] + [left_choice _.nil] + [right_choice //runtime.unit] ) (def: (with_looping in_closure? g!once g!continue? body!) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/reference.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/reference.lux index c08799435..47c60feac 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/reference.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/reference.lux @@ -9,5 +9,5 @@ (implementation: .public system (System Expression) - (def: constant _.global) - (def: variable _.local)) + (def: constant' _.global) + (def: variable' _.local)) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/runtime.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/runtime.lux index 782ae34f7..adf786058 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/runtime.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/runtime.lux @@ -171,47 +171,51 @@ (-> Nat Bit Expression Computation) (sum//make (_.int (.int tag)) (..flag last?) value)) -(def: .public none - Computation - (..variant 0 #0 ..unit)) - -(def: .public some - (-> Expression Computation) - (..variant 1 #1)) - (def: .public left (-> Expression Computation) (..variant 0 #0)) (def: .public right (-> Expression Computation) - (..variant 1 #1)) - -(runtime: (sum//get sum wantsLast wantedTag) - (let [no_match! (_.return _.nil) - sum_tag (_.item (_.string ..variant_tag_field) sum) - sum_flag (_.item (_.string ..variant_flag_field) sum) - sum_value (_.item (_.string ..variant_value_field) sum) - is_last? (_.= ..unit sum_flag) - test_recursion! (_.if is_last? - ... Must recurse. - ($_ _.then - (_.set (list wantedTag) (_.- sum_tag wantedTag)) - (_.set (list sum) sum_value)) - no_match!)] - (<| (_.while (_.bool true)) - (_.cond (list [(_.= sum_tag wantedTag) - (_.if (_.= wantsLast sum_flag) - (_.return sum_value) - test_recursion!)] + (..variant 0 #1)) - [(_.< wantedTag sum_tag) - test_recursion!] - - [(_.= ..unit wantsLast) - (_.return (sum//make (_.- wantedTag sum_tag) sum_flag sum_value))]) +(def: .public none + Computation + (..left ..unit)) - no_match!)))) +(def: .public some + (-> Expression Computation) + ..right) + +(runtime: (sum//get sum expected##right? expected##lefts) + (let [mismatch! (_.return _.nil) + actual##lefts (_.item (_.string ..variant_tag_field) sum) + actual##right? (_.item (_.string ..variant_flag_field) sum) + actual##value (_.item (_.string ..variant_value_field) sum) + recur! ($_ _.then + (_.set (list expected##lefts) (|> expected##lefts + (_.- actual##lefts) + (_.- (_.int +1)))) + (_.set (list sum) actual##value))] + (<| (_.while (_.bool true)) + (_.cond (list [(_.= expected##lefts actual##lefts) + (_.if (_.= expected##right? actual##right?) + (_.return actual##value) + mismatch!)] + + [(_.< expected##lefts actual##lefts) + (_.if (_.= ..unit actual##right?) + recur! + mismatch!)] + + [(_.= ..unit expected##right?) + (_.return (sum//make (|> actual##lefts + (_.- expected##lefts) + (_.- (_.int +1))) + actual##right? + actual##value))]) + + mismatch!)))) (def: runtime//adt Statement diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/structure.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/structure.lux index 6b9ddd993..72c620827 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/structure.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/ruby/structure.lux @@ -1,18 +1,18 @@ (.using - [library - [lux {"-" Variant Tuple} - [abstract - ["[0]" monad {"+" do}]] - [target - ["_" ruby {"+" Expression}]]]] - ["[0]" // "_" - ["[1][0]" runtime {"+" Operation Phase Generator}] - ["[1][0]" primitive] - ["///[1]" //// "_" - [analysis {"+" Variant Tuple}] - ["[1][0]" synthesis {"+" Synthesis}] - ["//[1]" /// "_" - ["[1][0]" phase ("[1]#[0]" monad)]]]]) + [library + [lux {"-" Variant Tuple} + [abstract + ["[0]" monad {"+" do}]] + [target + ["_" ruby {"+" Expression}]]]] + ["[0]" // "_" + ["[1][0]" runtime {"+" Operation Phase Generator}] + ["[1][0]" primitive] + ["///[1]" //// "_" + [analysis {"+" Variant Tuple}] + ["[1][0]" synthesis {"+" Synthesis}] + ["//[1]" /// "_" + ["[1][0]" phase ("[1]#[0]" monad)]]]]) (def: .public (tuple generate archive elemsS+) (Generator (Tuple Synthesis)) @@ -30,8 +30,5 @@ (def: .public (variant generate archive [lefts right? valueS]) (Generator (Variant Synthesis)) - (let [tag (if right? - (++ lefts) - lefts)] - (///////phase#each (//runtime.variant tag right?) - (generate archive valueS)))) + (///////phase#each (//runtime.variant lefts right?) + (generate archive valueS))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/synthesis.lux b/stdlib/source/library/lux/tool/compiler/language/lux/synthesis.lux index 56902d682..13d773310 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/synthesis.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/synthesis.lux @@ -816,7 +816,7 @@ [(template: .public (<name> idx nextP) [($_ ..path/seq (<side> idx) - ..#Pop + {..#Pop} nextP)])] [simple_left_side ..side/left] |