From 3a81232c2367df2416f62f651259ff9297abc7d4 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Tue, 14 Jun 2022 19:46:27 -0400 Subject: De-sigil-ification: suffix : [Part 9] --- lux-bootstrapper/project.clj | 4 +- lux-mode/lux-mode.el | 3 +- stdlib/source/documentation/lux/ffi.jvm.lux | 6 +- stdlib/source/documentation/lux/ffi.old.lux | 6 +- stdlib/source/library/lux/ffi.jvm.lux | 17 +++-- stdlib/source/library/lux/ffi.old.lux | 2 +- stdlib/source/library/lux/ffi/export.jvm.lux | 2 +- .../language/lux/phase/generation/extension.lux | 73 ++++++++++++---------- .../lux/phase/generation/r/procedure/common.lux | 53 ---------------- .../phase/generation/scheme/extension/common.lux | 46 -------------- stdlib/source/test/lux/ffi.jvm.lux | 26 ++++---- stdlib/source/test/lux/ffi.old.lux | 4 +- 12 files changed, 75 insertions(+), 167 deletions(-) diff --git a/lux-bootstrapper/project.clj b/lux-bootstrapper/project.clj index 1fb5bc5c9..28f798f47 100644 --- a/lux-bootstrapper/project.clj +++ b/lux-bootstrapper/project.clj @@ -1,4 +1,4 @@ -(def version "0.6.5") +(def version "0.6.6-SNAPSHOT") (defproject com.github.luxlang/lux-bootstrapper #=(identity version) :min-lein-version "2.1.0" ;; 2.1.0 introduced jar classifiers @@ -16,7 +16,7 @@ :dependencies [[org.clojure/clojure "1.6.0"] [org.clojure/core.match "0.2.1"] - [com.github.luxlang/lux-jvm-function ~version] + [com.github.luxlang/lux-jvm-function "0.6.5"] ;; Prefer when building JS compiler. [org.ow2.asm/asm "7.3.1"] diff --git a/lux-mode/lux-mode.el b/lux-mode/lux-mode.el index 8b79a6cf5..6979865fd 100644 --- a/lux-mode/lux-mode.el +++ b/lux-mode/lux-mode.el @@ -389,7 +389,7 @@ Called by `imenu--generic-function'." (code//super-quotation (altRE "``" "~~")) (code//template (altRE "with_template" "template")) ;; Miscellaneous - (jvm-host (altRE "import" "export" "class:" "interface" "object" "do_to" "synchronized" "class_for")) + (jvm-host (altRE "import" "export" "class" "interface" "object" "do_to" "synchronized" "class_for")) (alternative-format (altRE "char" "bin" "oct" "hex")) (documentation (altRE "comment" "documentation:")) (function-application (altRE "|>" "<|" "left" "right" "all")) @@ -590,6 +590,7 @@ This function also returns nil meaning don't specify the indentation." ("generation" 'defun) ("directive" 'defun) + ("class" 'defun) ("interface" 'defun) ("import" 'defun) ("export" 'defun) diff --git a/stdlib/source/documentation/lux/ffi.jvm.lux b/stdlib/source/documentation/lux/ffi.jvm.lux index 72a5e15cd..71e0c95a9 100644 --- a/stdlib/source/documentation/lux/ffi.jvm.lux +++ b/stdlib/source/documentation/lux/ffi.jvm.lux @@ -79,9 +79,9 @@ [/.short_to_char Short Character] ) -(documentation: /.class: +(documentation: /.class "Allows defining JVM classes in Lux code." - [(class: "final" (TestClass A) [Runnable] + [(class "final" (TestClass A) [Runnable] ... Fields ("private" foo boolean) ("private" bar A) @@ -305,7 +305,7 @@ ..byte_to_char ..short_to_char - ..class: + ..class ..interface ..object ..null diff --git a/stdlib/source/documentation/lux/ffi.old.lux b/stdlib/source/documentation/lux/ffi.old.lux index a93ecbe95..99f6a6c5b 100644 --- a/stdlib/source/documentation/lux/ffi.old.lux +++ b/stdlib/source/documentation/lux/ffi.old.lux @@ -45,9 +45,9 @@ [/.char_to_long "java.lang.Character" "java.lang.Long"] ) -(documentation: /.class: +(documentation: /.class "Allows defining JVM classes in Lux code." - [(class: "final" (TestClass A) [Runnable] + [(class "final" (TestClass A) [Runnable] ... Fields ("private" foo boolean) ("private" bar A) @@ -239,7 +239,7 @@ ..char_to_short ..char_to_int ..char_to_long - ..class: + ..class ..interface ..object ..null diff --git a/stdlib/source/library/lux/ffi.jvm.lux b/stdlib/source/library/lux/ffi.jvm.lux index f5ae643ad..9fc79a2d9 100644 --- a/stdlib/source/library/lux/ffi.jvm.lux +++ b/stdlib/source/library/lux/ffi.jvm.lux @@ -1203,7 +1203,7 @@ (Type Class) (jvm.class "java.lang.Object" (list))) -(def: .public class: +(def: .public class (syntax (_ [.let [! <>.monad] im inheritance_modifier^ [full_class_name class_vars] (at ! each parser.declaration ..declaration^) @@ -1656,15 +1656,12 @@ read (list (if _#import_field_static? (` {.#Right []}) (` {.#Right [(~ g!obj)]})) - (` ((~' in) (.list (.` (~ getter_body)))))) - - it (` (def: (~ g!name) - ((~! syntax) ((~ g!name) [(~ write|read) (~ parser)]) - (case (~ write|read) - (~+ write) - (~+ read))))) - _ ("lux io log" (%.format "[!] " (%.code it)))] - (list it))))) + (` ((~' in) (.list (.` (~ getter_body))))))] + (list (` (def: (~ g!name) + ((~! syntax) ((~ g!name) [(~ write|read) (~ parser)]) + (case (~ write|read) + (~+ write) + (~+ read)))))))))) ))) (def: (member_import$ vars kind class [import_format member]) diff --git a/stdlib/source/library/lux/ffi.old.lux b/stdlib/source/library/lux/ffi.old.lux index 92d7322fd..2fa4e5b7a 100644 --- a/stdlib/source/library/lux/ffi.old.lux +++ b/stdlib/source/library/lux/ffi.old.lux @@ -1202,7 +1202,7 @@ [#super_class_name "java/lang/Object" #super_class_params (list)]) -(def: .public class: +(def: .public class (syntax (_ [im inheritance_modifier^ class_decl ..class_decl^ .let [full_class_name (product.left class_decl)] diff --git a/stdlib/source/library/lux/ffi/export.jvm.lux b/stdlib/source/library/lux/ffi/export.jvm.lux index 163c98285..ed68b06d6 100644 --- a/stdlib/source/library/lux/ffi/export.jvm.lux +++ b/stdlib/source/library/lux/ffi/export.jvm.lux @@ -76,7 +76,7 @@ _ {.#None})) exports))] - (in (list (` (//.class: "final" (~ (code.local api)) + (in (list (` (//.class "final" (~ (code.local api)) (~+ (list#each (.function (_ it) (case it {#Constant [name type term]} diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/extension.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/extension.lux index aa9829172..78d2d4295 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/extension.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/extension.lux @@ -26,46 +26,55 @@ elemT .any]) (in (list (` [(~+ (list.repeated size elemT))]))))) -(type: .public (Nullary of) (-> (Vector 0 of) of)) -(type: .public (Unary of) (-> (Vector 1 of) of)) -(type: .public (Binary of) (-> (Vector 2 of) of)) -(type: .public (Trinary of) (-> (Vector 3 of) of)) -(type: .public (Variadic of) (-> (List of) of)) +(def: Arity + (template (_ arity) + [(All (_ of) + (-> (Vector arity of) of))])) -(def: arity: - (syntax (_ [arity .nat - name .local - type .any]) - (with_symbols [g!_ g!extension g!name g!phase g!archive g!inputs g!of g!anchor g!expression g!directive] +(def: arity + (syntax (_ [arity .nat]) + (with_symbols [g!_ g!extension g!name g!phase g!archive g!inputs g!anchor g!expression g!directive] (do [! meta.monad] [g!input+ (monad.all ! (list.repeated arity (macro.symbol "input")))] - (in (list (` (def: .public ((~ (code.local name)) (~ g!extension)) - (All ((~ g!_) (~ g!anchor) (~ g!expression) (~ g!directive)) - (-> ((~ type) (~ g!expression)) - (generation.Handler (~ g!anchor) (~ g!expression) (~ g!directive)))) - (function ((~ g!_) (~ g!name) (~ g!phase) (~ g!archive) (~ g!inputs)) - (case (~ g!inputs) - (pattern (list (~+ g!input+))) - (do ///.monad - [(~+ (|> g!input+ - (list#each (function (_ g!input) - (list g!input (` ((~ g!phase) (~ g!archive) (~ g!input)))))) - list.together))] - ((~' in) ((~ g!extension) [(~+ g!input+)]))) + (in (list (` (is (All ((~ g!_) (~ g!anchor) (~ g!expression) (~ g!directive)) + (-> ((Arity (~ (code.nat arity))) (~ g!expression)) + (generation.Handler (~ g!anchor) (~ g!expression) (~ g!directive)))) + (function ((~ g!_) (~ g!extension)) + (function ((~ g!_) (~ g!name) (~ g!phase) (~ g!archive) (~ g!inputs)) + (case (~ g!inputs) + (pattern (list (~+ g!input+))) + (do ///.monad + [(~+ (|> g!input+ + (list#each (function (_ g!input) + (list g!input (` ((~ g!phase) (~ g!archive) (~ g!input)))))) + list.together))] + ((~' in) ((~ g!extension) [(~+ g!input+)]))) - (~ g!_) - (///.except ///extension.incorrect_arity [(~ g!name) 1 (list.size (~ g!inputs))]))))))))))) + (~ g!_) + (///.except ///extension.incorrect_arity [(~ g!name) + (~ (code.nat arity)) + (list.size (~ g!inputs))])) + )))))))))) -(arity: 0 nullary ..Nullary) -(arity: 1 unary ..Unary) -(arity: 2 binary ..Binary) -(arity: 3 trinary ..Trinary) +(with_template [ ] + [(type: .public (Arity )) + (def: .public (arity ))] + + [0 Nullary nullary] + [1 Unary unary] + [2 Binary binary] + [3 Trinary trinary] + ) + +(type: .public (Variadic of) + (-> (List of) of)) (def: .public (variadic extension) (All (_ anchor expression directive) (-> (Variadic expression) (generation.Handler anchor expression directive))) (function (_ extension_name) (function (_ phase archive inputsS) - (do [! ///.monad] - [inputsI (monad.each ! (phase archive) inputsS)] - (in (extension inputsI)))))) + (let [! ///.monad] + (|> inputsS + (monad.each ! (phase archive)) + (at ! each extension)))))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/procedure/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/procedure/common.lux index 85f63171f..23f19d400 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/procedure/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/r/procedure/common.lux @@ -34,17 +34,6 @@ (type: .public Bundle (Dict Text Proc)) -(def: Vector - (syntax (_ [size .nat - elemT .any]) - (in (list (` [(~+ (list.repeated size elemT))]))))) - -(type: .public Nullary (-> (Vector +0 Expression) Expression)) -(type: .public Unary (-> (Vector +1 Expression) Expression)) -(type: .public Binary (-> (Vector +2 Expression) Expression)) -(type: .public Trinary (-> (Vector +3 Expression) Expression)) -(type: .public Variadic (-> (List Expression) Expression)) - ... [Utils] (def: .public (install name unnamed) (-> Text (-> Text Proc) @@ -58,48 +47,6 @@ (list/each (function (_ [key val]) [(format prefix " " key) val])) (dict.from_list text.Hash))) -(def: (wrong_arity proc expected actual) - (-> Text Nat Nat Text) - (format "Wrong number of arguments for " (%t proc) "\n" - "Expected: " (|> expected .int %i) "\n" - " Actual: " (|> actual .int %i))) - -(def: arity: - (syntax (_ [name s.local - arity s.nat]) - (with_symbols [g!_ g!proc g!name g!translate g!inputs] - (do [@ macro.monad] - [g!input+ (monad.all @ (list.repeated arity (macro.symbol "input")))] - (in (list (` (def: .public ((~ (code.local name)) (~ g!proc)) - (-> (-> (..Vector (~ (code.nat arity)) Expression) Expression) - (-> Text ..Proc)) - (function ((~ g!_) (~ g!name)) - (function ((~ g!_) (~ g!translate) (~ g!inputs)) - (case (~ g!inputs) - (pattern (list (~+ g!input+))) - (do macro.Monad - [(~+ (|> g!input+ - (list/each (function (_ g!input) - (list g!input (` ((~ g!translate) (~ g!input)))))) - list.together))] - ((~' in) ((~ g!proc) [(~+ g!input+)]))) - - (~' _) - (macro.failure (wrong_arity (~ g!name) +1 (list.size (~ g!inputs))))))))))))))) - -(arity: nullary +0) -(arity: unary +1) -(arity: binary +2) -(arity: trinary +3) - -(def: .public (variadic proc) - (-> Variadic (-> Text Proc)) - (function (_ proc_name) - (function (_ translate inputsS) - (do [@ macro.Monad] - [inputsI (monad.each @ translate inputsS)] - (in (proc inputsI)))))) - ... [Procedures] ... [[Lux]] (def: (lux//is [leftO rightO]) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/extension/common.lux b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/extension/common.lux index 3bf0659ba..2ed9653b5 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/extension/common.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/phase/generation/scheme/extension/common.lux @@ -28,52 +28,6 @@ ["[1]/" // ["[1][0]" synthesis (.only Synthesis)]]]]) -(def: Vector - (syntax (_ [size .nat - elemT .any]) - (in (list (` [(~+ (list.repeated size elemT))]))))) - -(type: .public Nullary (-> (Vector 0 Expression) Computation)) -(type: .public Unary (-> (Vector 1 Expression) Computation)) -(type: .public Binary (-> (Vector 2 Expression) Computation)) -(type: .public Trinary (-> (Vector 3 Expression) Computation)) -(type: .public Variadic (-> (List Expression) Computation)) - -(def: arity: - (syntax (_ [name .local - arity .nat]) - (with_symbols [g!_ g!extension g!name g!phase g!inputs] - (do [! macro.monad] - [g!input+ (monad.all ! (list.repeated arity (macro.symbol "input")))] - (in (list (` (def: .public ((~ (code.local name)) (~ g!extension)) - (-> (-> (..Vector (~ (code.nat arity)) Expression) Computation) - Handler) - (function ((~ g!_) (~ g!name) (~ g!phase) (~ g!inputs)) - (case (~ g!inputs) - (pattern (list (~+ g!input+))) - (do /////.monad - [(~+ (|> g!input+ - (list#each (function (_ g!input) - (list g!input (` ((~ g!phase) (~ g!input)))))) - list.together))] - ((~' in) ((~ g!extension) [(~+ g!input+)]))) - - (~' _) - (/////.except /////extension.incorrect_arity [(~ g!name) 1 (list.size (~ g!inputs))]))))))))))) - -(arity: nullary 0) -(arity: unary 1) -(arity: binary 2) -(arity: trinary 3) - -(def: .public (variadic extension) - (-> Variadic Handler) - (function (_ extension_name) - (function (_ phase inputsS) - (do [! /////.monad] - [inputsI (monad.each ! phase inputsS)] - (in (extension inputsI)))))) - (def: bundle::lux Bundle (|> bundle.empty diff --git a/stdlib/source/test/lux/ffi.jvm.lux b/stdlib/source/test/lux/ffi.jvm.lux index d30eee0ae..327c2c77f 100644 --- a/stdlib/source/test/lux/ffi.jvm.lux +++ b/stdlib/source/test/lux/ffi.jvm.lux @@ -377,7 +377,7 @@ example/3! example/4!)))) -(/.class: "final" test/TestClass0 [test/TestInterface0] +(/.class "final" test/TestClass0 [test/TestInterface0] ... Fields ("private" value java/lang/Long) ... Constructors @@ -392,7 +392,7 @@ "[1]::[0]" (new [java/lang/Long])) -(/.class: "final" test/TestClass1 [test/TestInterface1] +(/.class "final" test/TestClass1 [test/TestInterface1] ... Fields ("private" value java/lang/Long) ... Constructors @@ -410,7 +410,7 @@ "[1]::[0]" (new [java/lang/Long])) -(/.class: "final" test/TestClass2 [test/TestInterface2] +(/.class "final" test/TestClass2 [test/TestInterface2] ... Constructors ("public" [] (new self []) [] []) @@ -424,7 +424,7 @@ "[1]::[0]" (new [])) -(/.class: "final" (test/TestClass3 a) [(test/TestInterface3 a)] +(/.class "final" (test/TestClass3 a) [(test/TestInterface3 a)] ... Fields ("private" value a) ... Constructors @@ -440,7 +440,7 @@ "[1]::[0]" (new [a])) -(/.class: "final" test/TestClass4 [] +(/.class "final" test/TestClass4 [] ... Constructors ("public" [] (new self []) [] []) @@ -453,7 +453,7 @@ (new []) (actual4 [java/lang/Long] java/lang/Long)) -(/.class: "final" test/TestClass5 [] +(/.class "final" test/TestClass5 [] ... Constructors ("public" [] (new self []) [] []) @@ -466,7 +466,7 @@ "[1]::[0]" ("static" actual5 [java/lang/Long] java/lang/Long)) -(/.class: "abstract" test/TestClass6 [] +(/.class "abstract" test/TestClass6 [] ... Constructors ("public" [] (new self []) [] []) @@ -478,7 +478,7 @@ "[1]::[0]" (actual6 [java/lang/Long] java/lang/Long)) -(/.class: "final" test/TestClass7 test/TestClass6 [] +(/.class "final" test/TestClass7 test/TestClass6 [] ... Constructors ("public" [] (new self []) [] []) @@ -492,7 +492,7 @@ "[1]::[0]" (new [])) -(/.class: "final" test/TestClass8 [test/TestInterface4] +(/.class "final" test/TestClass8 [test/TestInterface4] ... Constructors ("public" [] (new self []) [] []) @@ -509,7 +509,7 @@ "[1]::[0]" (new [])) -(/.class: "final" (test/TestClass9 a) [] +(/.class "final" (test/TestClass9 a) [] ... Fields ("private" value9 a) ... Constructors @@ -527,7 +527,7 @@ (set_actual9 [a] void) (get_actual9 [] a)) -(/.class: "final" (test/TestClass10 a) [] +(/.class "final" (test/TestClass10 a) [] ... Fields ("public" value10 a) ... Constructors @@ -539,7 +539,7 @@ (new [a]) (value10 a)) -(/.class: "final" (test/TestClass11 a) [] +(/.class "final" (test/TestClass11 a) [] ... Fields ("public" value11 a) ... Constructors @@ -651,7 +651,7 @@ macro_error (text.contains? (the exception.#label /.cannot_write_to_field))))]] (all _.and - (_.coverage [/.class: /.import] + (_.coverage [/.class /.import] (and example/0! example/1! example/2! diff --git a/stdlib/source/test/lux/ffi.old.lux b/stdlib/source/test/lux/ffi.old.lux index b00020c6c..917e18949 100644 --- a/stdlib/source/test/lux/ffi.old.lux +++ b/stdlib/source/test/lux/ffi.old.lux @@ -36,7 +36,7 @@ "[1]::[0]" (getName [] java/lang/String)) -(/.class: "final" (TestClass A) [] +(/.class "final" (TestClass A) [] ... Fields ("private" increase java/lang/Long) ("private" counter java/lang/Long) @@ -212,7 +212,7 @@ (|> (/.class_for java/lang/Class) java/lang/Class::getName (text#= "java.lang.Class"))) - (_.coverage [/.class: /.do_to] + (_.coverage [/.class /.do_to] (|> (/.do_to (test/lux/ffi/TestClass::new increase counter) (test/lux/ffi/TestClass::upC) (test/lux/ffi/TestClass::upC) -- cgit v1.2.3