From 4f939136769d9a3f64088115e3b48f0e491c7c37 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Thu, 10 Oct 2019 18:00:28 -0400 Subject: Small improvements + fixes --- commands.md | 76 +++++++-------- lux-mode/lux-mode.el | 220 +++++++++++++++++++++--------------------- luxc/src/lux/analyser/lux.clj | 2 +- luxc/src/lux/base.clj | 4 +- luxc/src/lux/compiler.clj | 2 +- luxc/src/lux/compiler/jvm.clj | 14 +-- luxc/src/lux/lib/loader.clj | 1 - luxc/src/lux/type.clj | 14 +-- 8 files changed, 166 insertions(+), 167 deletions(-) diff --git a/commands.md b/commands.md index a72de6c0b..43d5838a8 100644 --- a/commands.md +++ b/commands.md @@ -54,20 +54,20 @@ cd ~/lux/lux-lein/ && lein install ## Test ``` -cd ~/lux/stdlib/ && lein clean && lein_2_7_1 with-profile bibliotheca lux auto test -cd ~/lux/stdlib/ && lein_2_7_1 with-profile bibliotheca lux auto test +cd ~/lux/stdlib/ && lein clean && lein with-profile bibliotheca lux auto test +cd ~/lux/stdlib/ && lein with-profile bibliotheca lux auto test ``` ## Install ``` -cd ~/lux/stdlib/ && lein_2_7_1 install +cd ~/lux/stdlib/ && lein install ``` ## Generate documentation ``` -cd ~/lux/stdlib/ && lein_2_7_1 with-profile scriptum lux auto build +cd ~/lux/stdlib/ && lein with-profile scriptum lux auto build ``` --- @@ -77,13 +77,13 @@ cd ~/lux/stdlib/ && lein_2_7_1 with-profile scriptum lux auto build ## Build ``` -cd ~/lux/stdlib/ && lein_2_7_1 with-profile licentia lux auto build +cd ~/lux/stdlib/ && lein with-profile licentia lux auto build ``` ## Test ``` -cd ~/lux/stdlib/ && lein_2_7_1 with-profile licentia lux auto test +cd ~/lux/stdlib/ && lein with-profile licentia lux auto test ``` ## Run @@ -99,15 +99,15 @@ cd ~/lux/stdlib/ && java -jar target/program.jar --input ../license.json --outpu ## Test ``` -cd ~/lux/lux-js/ && lein_2_7_1 lux auto test -cd ~/lux/lux-js/ && lein clean && lein_2_7_1 lux auto test +cd ~/lux/lux-js/ && lein lux auto test +cd ~/lux/lux-js/ && lein clean && lein lux auto test ``` ## Build ``` -cd ~/lux/lux-js/ && lein_2_7_1 lux auto build -cd ~/lux/lux-js/ && lein clean && lein_2_7_1 lux auto build +cd ~/lux/lux-js/ && lein lux auto build +cd ~/lux/lux-js/ && lein clean && lein lux auto build ``` ## Try @@ -123,15 +123,15 @@ cd ~/lux/lux-js/ && time java -jar target/program.jar build --source ~/lux/stdli ## Test ``` -cd ~/lux/lux-python/ && lein_2_7_1 lux auto test -cd ~/lux/lux-python/ && lein clean && lein_2_7_1 lux auto test +cd ~/lux/lux-python/ && lein lux auto test +cd ~/lux/lux-python/ && lein clean && lein lux auto test ``` ## Build ``` -cd ~/lux/lux-python/ && lein_2_7_1 lux auto build -cd ~/lux/lux-python/ && lein clean && lein_2_7_1 lux auto build +cd ~/lux/lux-python/ && lein lux auto build +cd ~/lux/lux-python/ && lein clean && lein lux auto build ``` ## Try @@ -147,15 +147,15 @@ cd ~/lux/lux-python/ && java -jar target/program.jar build --source ~/lux/stdlib ## Test ``` -cd ~/lux/lux-lua/ && lein_2_7_1 lux auto test -cd ~/lux/lux-lua/ && lein clean && lein_2_7_1 lux auto test +cd ~/lux/lux-lua/ && lein lux auto test +cd ~/lux/lux-lua/ && lein clean && lein lux auto test ``` ## Build ``` -cd ~/lux/lux-lua/ && lein_2_7_1 lux auto build -cd ~/lux/lux-lua/ && lein clean && lein_2_7_1 lux auto build +cd ~/lux/lux-lua/ && lein lux auto build +cd ~/lux/lux-lua/ && lein clean && lein lux auto build ``` ## Try @@ -171,15 +171,15 @@ cd ~/lux/lux-lua/ && java -jar target/program.jar build --source ~/lux/stdlib/so ## Test ``` -cd ~/lux/lux-ruby/ && lein_2_7_1 lux auto test -cd ~/lux/lux-ruby/ && lein clean && lein_2_7_1 lux auto test +cd ~/lux/lux-ruby/ && lein lux auto test +cd ~/lux/lux-ruby/ && lein clean && lein lux auto test ``` ## Build ``` -cd ~/lux/lux-ruby/ && lein_2_7_1 lux auto build -cd ~/lux/lux-ruby/ && lein clean && lein_2_7_1 lux auto build +cd ~/lux/lux-ruby/ && lein lux auto build +cd ~/lux/lux-ruby/ && lein clean && lein lux auto build ``` ## Try @@ -195,15 +195,15 @@ cd ~/lux/lux-ruby/ && java -jar target/program.jar build --source ~/lux/stdlib/s ## Test ``` -cd ~/lux/lux-php/ && lein_2_7_1 lux auto test -cd ~/lux/lux-php/ && lein clean && lein_2_7_1 lux auto test +cd ~/lux/lux-php/ && lein lux auto test +cd ~/lux/lux-php/ && lein clean && lein lux auto test ``` ## Build ``` -cd ~/lux/lux-php/ && lein_2_7_1 lux auto build -cd ~/lux/lux-php/ && lein clean && lein_2_7_1 lux auto build +cd ~/lux/lux-php/ && lein lux auto build +cd ~/lux/lux-php/ && lein clean && lein lux auto build ``` ## Try @@ -219,15 +219,15 @@ cd ~/lux/lux-php/ && java -jar target/program.jar build --source ~/lux/stdlib/so ## Test ``` -cd ~/lux/lux-cl/ && lein_2_7_1 lux auto test -cd ~/lux/lux-cl/ && lein clean && lein_2_7_1 lux auto test +cd ~/lux/lux-cl/ && lein lux auto test +cd ~/lux/lux-cl/ && lein clean && lein lux auto test ``` ## Build ``` -cd ~/lux/lux-cl/ && lein_2_7_1 lux auto build -cd ~/lux/lux-cl/ && lein clean && lein_2_7_1 lux auto build +cd ~/lux/lux-cl/ && lein lux auto build +cd ~/lux/lux-cl/ && lein clean && lein lux auto build ``` ## Try @@ -243,15 +243,15 @@ cd ~/lux/lux-cl/ && java -jar target/program.jar build --source ~/lux/stdlib/sou ## Test ``` -cd ~/lux/lux-scheme/ && lein_2_7_1 lux auto test -cd ~/lux/lux-scheme/ && lein clean && lein_2_7_1 lux auto test +cd ~/lux/lux-scheme/ && lein lux auto test +cd ~/lux/lux-scheme/ && lein clean && lein lux auto test ``` ## Build ``` -cd ~/lux/lux-scheme/ && lein_2_7_1 lux auto build -cd ~/lux/lux-scheme/ && lein clean && lein_2_7_1 lux auto build +cd ~/lux/lux-scheme/ && lein lux auto build +cd ~/lux/lux-scheme/ && lein clean && lein lux auto build ``` ## Try @@ -267,15 +267,15 @@ cd ~/lux/lux-scheme/ && java -jar target/program.jar build --source ~/lux/stdlib ## Test ``` -cd ~/lux/new-luxc/ && lein_2_7_1 lux auto test -cd ~/lux/new-luxc/ && lein clean && lein_2_7_1 lux auto test +cd ~/lux/new-luxc/ && lein lux auto test +cd ~/lux/new-luxc/ && lein clean && lein lux auto test ``` ## Build ``` -cd ~/lux/new-luxc/ && lein_2_7_1 lux auto build -cd ~/lux/new-luxc/ && lein clean && lein_2_7_1 lux auto build +cd ~/lux/new-luxc/ && lein lux auto build +cd ~/lux/new-luxc/ && lein clean && lein lux auto build ``` # REPL diff --git a/lux-mode/lux-mode.el b/lux-mode/lux-mode.el index 860952e43..7f67ac1f0 100644 --- a/lux-mode/lux-mode.el +++ b/lux-mode/lux-mode.el @@ -218,115 +218,115 @@ Called by `imenu--generic-function'." (defconst lux-font-lock-keywords (eval-when-compile - (let ((natural "[0-9][0-9,]*") - (identifier_h "[a-zA-Z-\\+_=!@\\$%\\^&\\*<>;,/\\\\\\|':~\\?]") - (identifier_t "[a-zA-Z0-9-\\+_=!@\\$%\\^&\\*<>;,/\\\\\\|':~\\?]") - (sign (altRE "-" "\\+"))) - (let ((identifier (concat identifier_h identifier_t "*")) - (integer (concat sign natural))) - (let ((bitRE (literal (special (altRE "0" "1")))) - (natRE (literal natural)) - (int&fracRE (literal (concat integer "\\(\\." natural "\\(\\(e\\|E\\)" integer "\\)?\\)?"))) - (revRE (literal (concat "\\." natural))) - (tagRE (let ((separator "\\.")) - (let ((in-prelude separator) - (in-current-module (concat separator separator)) - (in-module (concat identifier separator)) - (in-local "")) - (special (concat (altRE in-prelude - in-current-module - in-module in-local) - identifier))))) - (specialRE (let (;; Control - (control//flow (altRE "case" "exec" "let" "if" "cond" "loop" "recur" "do" "be")) - (control//pattern-matching (altRE "\\^" "\\^or" "\\^slots" - "\\^multi" "\\^@" "\\^template" - "\\^open" "\\^|>" "\\^code" - "\\^sequence&" "\\^regex")) - (control//logic (altRE "and" "or")) - (control//contract (altRE "pre" "post")) - ;; Type - (type//syntax (altRE "|" "&" "->" "All" "Ex" "Rec" "primitive" "\\$" "type")) - (type//checking (altRE ":" ":coerce" ":let" ":~" ":assume" ":of" ":cast" ":share" ":by-example" ":hole")) - (type//abstract (altRE "abstract:" ":abstraction" ":representation" ":transmutation" "\\^:representation")) - (type//unit (altRE "unit:" "scale:")) - (type//poly (altRE "poly:" "derived:")) - (type//dynamic (altRE ":dynamic" ":check")) - (type//capability (altRE "capability:")) - ;; Data - (data//record (altRE "get@" "set@" "update@")) - (data//signature (altRE "signature:" "structure:" "open:" "structure" "::")) - (data//implicit (altRE "implicit:" "implicit" ":::")) - (data//collection (altRE "list" "list&" "row" "tree")) - ;; Code - (code//quotation (altRE "`" "`'" "'" "~" "~\\+" "~!" "~'")) - (code//super-quotation (altRE "``" "~~")) - (code//template (altRE "template" "template:")) - ;; Miscellaneous - (actor (altRE "actor:" "message:" "on:")) - (jvm-host (altRE "class:" "interface:" "import:" "object" "do-to" "synchronized" "class-for")) - (alternative-format (altRE "char" "bin" "oct" "hex")) - (documentation (altRE "doc" "comment")) - (function-application (altRE "|>" "|>>" "<|" "<<|" "_\\$" "\\$_")) - (remember (altRE "remember" "to-do" "fix-me"))) - (let ((control (altRE control//flow - control//pattern-matching - control//logic - control//contract)) - (type (altRE type//syntax - type//checking - type//abstract - type//unit - type//poly - type//dynamic - type//capability)) - (data (altRE data//record - data//signature - data//implicit - data//collection)) - (code (altRE code//quotation - code//super-quotation - code//template))) - (concat - "(" - (altRE - control - type - data - code -;;;;;;;;;;;;;;;;;;;;;;;; - actor - jvm-host - alternative-format - documentation - function-application - remember -;;;;;;;;;;;;;;;;;;;;;;;; - "\\.module:" - "def:" "type:" "program:" - "macro:" "syntax:" - "with-expansions" - "exception:" - "word:" - "function" "undefined" "name-of" "static" - "for" "io" - "infix" - "format" - "regex") - "\\>"))))) - `(;; Special forms - (,specialRE 1 font-lock-builtin-face) - ;; Bit literals - (,bitRE 0 font-lock-constant-face) - ;; Nat literals - (,natRE 0 font-lock-constant-face) - ;; Int literals && Frac literals - (,int&fracRE 0 font-lock-constant-face) - ;; Rev literals - (,revRE 0 font-lock-constant-face) - ;; Tags - (,tagRE 0 font-lock-type-face) - ))))) + (let* ((natural "[0-9][0-9,]*") + (identifier_h "[a-zA-Z-\\+_=!@\\$%\\^&\\*<>;,/\\\\\\|':~\\?]") + (identifier_t "[a-zA-Z0-9-\\+_=!@\\$%\\^&\\*<>;,/\\\\\\|':~\\?]") + (sign (altRE "-" "\\+")) + (identifier (concat identifier_h identifier_t "*")) + (integer (concat sign natural)) + (bitRE (literal (special (altRE "0" "1")))) + (natRE (literal natural)) + (int&fracRE (literal (concat integer "\\(\\." natural "\\(\\(e\\|E\\)" integer "\\)?\\)?"))) + (revRE (literal (concat "\\." natural))) + (tagRE (let ((separator "\\.")) + (let ((in-prelude separator) + (in-current-module (concat separator separator)) + (in-module (concat identifier separator)) + (in-local "")) + (special (concat (altRE in-prelude + in-current-module + in-module in-local) + identifier))))) + (specialRE (let (;; Control + (control//flow (altRE "case" "exec" "let" "if" "cond" "loop" "recur" "do" "be")) + (control//pattern-matching (altRE "\\^" "\\^or" "\\^slots" + "\\^multi" "\\^@" "\\^template" + "\\^open" "\\^|>" "\\^code" + "\\^sequence&" "\\^regex")) + (control//logic (altRE "and" "or")) + (control//contract (altRE "pre" "post")) + ;; Type + (type//syntax (altRE "|" "&" "->" "All" "Ex" "Rec" "primitive" "\\$" "type")) + (type//checking (altRE ":" ":coerce" ":let" ":~" ":assume" ":of" ":cast" ":share" ":by-example" ":hole")) + (type//abstract (altRE "abstract:" ":abstraction" ":representation" ":transmutation" "\\^:representation")) + (type//unit (altRE "unit:" "scale:")) + (type//poly (altRE "poly:" "derived:")) + (type//dynamic (altRE ":dynamic" ":check")) + (type//capability (altRE "capability:")) + ;; Data + (data//record (altRE "get@" "set@" "update@")) + (data//signature (altRE "signature:" "structure:" "open:" "structure" "::")) + (data//implicit (altRE "implicit:" "implicit" ":::")) + (data//collection (altRE "list" "list&" "row" "tree")) + ;; Code + (code//quotation (altRE "`" "`'" "'" "~" "~\\+" "~!" "~'")) + (code//super-quotation (altRE "``" "~~")) + (code//template (altRE "template" "template:")) + ;; Miscellaneous + (actor (altRE "actor:" "message:" "on:")) + (jvm-host (altRE "class:" "interface:" "import:" "object" "do-to" "synchronized" "class-for")) + (alternative-format (altRE "char" "bin" "oct" "hex")) + (documentation (altRE "doc" "comment")) + (function-application (altRE "|>" "|>>" "<|" "<<|" "_\\$" "\\$_")) + (remember (altRE "remember" "to-do" "fix-me"))) + (let ((control (altRE control//flow + control//pattern-matching + control//logic + control//contract)) + (type (altRE type//syntax + type//checking + type//abstract + type//unit + type//poly + type//dynamic + type//capability)) + (data (altRE data//record + data//signature + data//implicit + data//collection)) + (code (altRE code//quotation + code//super-quotation + code//template))) + (concat + "(" + (altRE + control + type + data + code + ;; ;;;;;;;;;;;;;;;;;;;;;; + actor + jvm-host + alternative-format + documentation + function-application + remember + ;; ;;;;;;;;;;;;;;;;;;;;;; + "\\.module:" + "def:" "type:" "program:" + "macro:" "syntax:" + "with-expansions" + "exception:" + "word:" + "function" "undefined" "name-of" "static" + "for" "io" + "infix" + "format" + "regex") + "\\>"))))) + `(;; Special forms + (,specialRE 1 font-lock-builtin-face) + ;; Bit literals + (,bitRE 0 font-lock-constant-face) + ;; Nat literals + (,natRE 0 font-lock-constant-face) + ;; Int literals && Frac literals + (,int&fracRE 0 font-lock-constant-face) + ;; Rev literals + (,revRE 0 font-lock-constant-face) + ;; Tags + (,tagRE 0 font-lock-type-face) + ))) "Default expressions to highlight in Lux mode.") (defun lux-font-lock-syntactic-face-function (state) @@ -430,7 +430,7 @@ This function also returns nil meaning don't specify the indentation." "Call `put-lux-indent' on a series, KVS." `(progn ,@(mapcar (lambda (x) `(put-lux-indent - (quote ,(first x)) ,(second x))) + (quote ,(first x)) ,(second x))) kvs))) (define-lux-indent diff --git a/luxc/src/lux/analyser/lux.clj b/luxc/src/lux/analyser/lux.clj index 8a2f4b70c..eb412bf0c 100644 --- a/luxc/src/lux/analyser/lux.clj +++ b/luxc/src/lux/analyser/lux.clj @@ -395,7 +395,7 @@ ;; (->> macro-expansion ;; (&/|map (fn [ast] (str (&/show-ast ast) "\n"))) ;; (&/fold str "") - ;; (&/|log! (str 'macro-expansion " " (&/ident->text real-name) " @ " module-name "\n"))))] + ;; (&/|log! (str 'macro-expansion " " (&/ident->text real-name) " @ " module-name))))] ] (&/flat-map% (partial analyse exo-type) macro-expansion)) (do-analyse-apply analyse exo-type =fn ?args))) diff --git a/luxc/src/lux/base.clj b/luxc/src/lux/base.clj index f91bc4f2a..9a0bc1b5a 100644 --- a/luxc/src/lux/base.clj +++ b/luxc/src/lux/base.clj @@ -965,7 +965,7 @@ (let [!out! *out*] (defn |log! [& parts] (binding [*out* !out!] - (do (print (apply str parts)) + (do (print (str (apply str parts) "\n")) (flush))))) (defn |last [xs] @@ -1480,7 +1480,7 @@ ($Right state* output) (let [post (System/currentTimeMillis) duration (- post pre) - _ (|log! (str what " [" when "]: +" duration "ms" "\n"))] + _ (|log! (str what " [" when "]: +" duration "ms"))] ($Right (T [state* output]))) ($Left ^String msg) diff --git a/luxc/src/lux/compiler.clj b/luxc/src/lux/compiler.clj index 2f46d2506..a3e60e463 100644 --- a/luxc/src/lux/compiler.clj +++ b/luxc/src/lux/compiler.clj @@ -26,4 +26,4 @@ (defn compile-program [mode program-module dependencies source-dirs target-dir] (init! dependencies target-dir) - (&&jvm/compile-program mode program-module dependencies source-dirs)) + (&&jvm/compile-program mode program-module source-dirs)) diff --git a/luxc/src/lux/compiler/jvm.clj b/luxc/src/lux/compiler/jvm.clj index bcde7a8ea..5ed579116 100644 --- a/luxc/src/lux/compiler/jvm.clj +++ b/luxc/src/lux/compiler/jvm.clj @@ -174,7 +174,7 @@ (let [+field-flags+ (+ Opcodes/ACC_PUBLIC Opcodes/ACC_FINAL Opcodes/ACC_STATIC) +datum-sig+ "Ljava/lang/Object;"] - (defn compile-module [compile-module source-dirs name] + (defn compile-module [source-dirs name] (|do [[file-name file-content] (&&io/read-file source-dirs name) :let [file-hash (hash file-content) compile-module!! (&¶llel/parallel-compilation (partial compile-module source-dirs))]] @@ -217,9 +217,9 @@ (proxy [java.lang.ClassLoader] [] (findClass [^String class-name] - (if-let [^bytes bytecode (get @store class-name)] - (.invoke define-class this (to-array [class-name bytecode (int 0) (int (alength bytecode))])) - (throw (IllegalStateException. (str "[Class Loader] Unknown class: " class-name)))))))) + (if-let [^bytes bytecode (get @store class-name)] + (.invoke define-class this (to-array [class-name bytecode (int 0) (int (alength bytecode))])) + (throw (IllegalStateException. (str "[Class Loader] Unknown class: " class-name)))))))) (defn jvm-host [] (let [store (atom {})] @@ -236,13 +236,13 @@ ])))) (let [!err! *err*] - (defn compile-program [mode program-module dependencies source-dirs] + (defn compile-program [mode program-module source-dirs] (let [m-action (|do [_ (&&cache/pre-load-cache! source-dirs &&jvm-cache/load-def-value &&jvm-cache/install-all-defs-in-module &&jvm-cache/uninstall-all-defs-in-module) - _ (compile-module dependencies source-dirs "lux")] - (compile-module dependencies source-dirs program-module))] + _ (compile-module source-dirs "lux")] + (compile-module source-dirs program-module))] (|case (m-action (&/init-state "{old}" mode (jvm-host))) (&/$Right ?state _) (do (println "Compilation complete!") diff --git a/luxc/src/lux/lib/loader.clj b/luxc/src/lux/lib/loader.clj index 5afae6ae2..97e6ee684 100644 --- a/luxc/src/lux/lib/loader.clj +++ b/luxc/src/lux/lib/loader.clj @@ -36,7 +36,6 @@ ;; [Exports] (defn load [dependencies] - (prn `load (&/->seq dependencies)) (->> dependencies &/->seq (map #(->> ^String % (new File) unpackage)) diff --git a/luxc/src/lux/type.clj b/luxc/src/lux/type.clj index fc1736a1c..ae80d1142 100644 --- a/luxc/src/lux/type.clj +++ b/luxc/src/lux/type.clj @@ -746,13 +746,13 @@ [(&/$Apply A F) _] (let [fp-pair (&/T [expected actual]) _ (when (> (&/|length fixpoints) max-stack-size) - (&/|log! (println-str 'FIXPOINTS (->> (&/|keys fixpoints) - (&/|map (fn [pair] - (|let [[e a] pair] - (str (show-type e) ":+:" - (show-type a))))) - (&/|interpose "\n\n") - (&/fold str "")))) + (&/|log! (print-str 'FIXPOINTS (->> (&/|keys fixpoints) + (&/|map (fn [pair] + (|let [[e a] pair] + (str (show-type e) ":+:" + (show-type a))))) + (&/|interpose "\n\n") + (&/fold str "")))) (assert false (prn-str 'check* '[(&/$Apply A F) _] (&/|length fixpoints) (show-type expected) (show-type actual))))] (|case (fp-get fp-pair fixpoints) (&/$Some ?) -- cgit v1.2.3