From 717ed15dc264d26a642adf22137fac6d526aff25 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Wed, 23 May 2018 21:23:57 -0400 Subject: - Minor improvements. --- lux-mode/lux-mode.el | 4 +- stdlib/source/lux.lux | 36 +++++------------ .../source/lux/data/coll/dictionary/unordered.lux | 10 ++--- stdlib/source/lux/lang/init.lux | 47 ++++++++++++---------- stdlib/source/lux/lang/target.lux | 18 +++++++++ 5 files changed, 59 insertions(+), 56 deletions(-) create mode 100644 stdlib/source/lux/lang/target.lux diff --git a/lux-mode/lux-mode.el b/lux-mode/lux-mode.el index 663f421cb..c8a3b89e0 100644 --- a/lux-mode/lux-mode.el +++ b/lux-mode/lux-mode.el @@ -224,7 +224,7 @@ Called by `imenu--generic-function'." "word:" "abstract:" "unit:" "scale:" - "function" "case" ":" ":!" ":!!" "undefined" "ident-for" + "function" "case" ":" ":!" ":!!" "undefined" "ident-for" "static" "and" "or" "char" "exec" "let" "if" "cond" "do" "be" "open" "loop" "recur" "comment" "for" @@ -232,7 +232,7 @@ Called by `imenu--generic-function'." "get@" "set@" "update@" "|>" "|>>" "<|" "<<|" "_$" "$_" "~" "~+" "~!" "~'" "::" ":::" "|" "&" "->" "All" "Ex" "Rec" "primitive" "$" "type" "@abstraction" "@representation" "^@representation" - "^" "^or" "^slots" "^multi" "^~" "^@" "^template" "^open" "^|>" "^code" "^stream&" "^regex" + "^" "^or" "^slots" "^multi" "^@" "^template" "^open" "^|>" "^code" "^stream&" "^regex" "bin" "oct" "hex" "pre" "post" "sig" "struct" "derive" diff --git a/stdlib/source/lux.lux b/stdlib/source/lux.lux index d6a399463..b84b0d096 100644 --- a/stdlib/source/lux.lux +++ b/stdlib/source/lux.lux @@ -700,8 +700,8 @@ ## #expected (Maybe Type) ## #seed Nat ## #scope-type-vars (List Nat) -## #extensions Nothing -## #host Nothing}) +## #extensions Any +## #host Any}) ("lux def" Lux (#Named ["lux" "Lux"] (#Product ## "lux.info" @@ -725,9 +725,9 @@ (#Product ## scope-type-vars (#Apply Nat List) (#Product ## extensions - Nothing + Any ## "lux.host" - Nothing)))))))))))) + Any)))))))))))) (record$ (#Cons [(tag$ ["lux" "tags"]) (tuple$ (#Cons (text$ "info") (#Cons (text$ "source") @@ -5723,33 +5723,15 @@ (:: Monad return token) )) -(macro: #export (^~ tokens) - {#.doc (doc "Use global definitions with simple values, such as text, int, frac and bool in place of literals in patterns." - "The definitions must be properly-qualified (though you may use one of the short-cuts Lux provides)." - (def: (empty?' node) - (All [K V] (-> (Node K V) Bool)) - (case node - (^~ (#Base ..clean-bitmap _)) - true - - _ - false)))} +(macro: #export (static tokens) (case tokens - (^ (list& [_ (#Form (list pattern))] body branches)) + (^ (list pattern)) (do Monad - [module-name current-module-name - pattern+ (macro-expand-all pattern)] - (case pattern+ - (^ (list pattern')) - (do Monad - [pattern'' (anti-quote pattern')] - (wrap (list& pattern'' body branches))) - - _ - (fail "^~ can only expand to 1 pattern."))) + [pattern' (anti-quote pattern)] + (wrap (list pattern'))) _ - (fail "Wrong syntax for ^~"))) + (fail "Wrong syntax for \"static\"."))) (type: Multi-Level-Case [Code (List [Code Code])]) diff --git a/stdlib/source/lux/data/coll/dictionary/unordered.lux b/stdlib/source/lux/data/coll/dictionary/unordered.lux index 053d53d48..12c58a2fd 100644 --- a/stdlib/source/lux/data/coll/dictionary/unordered.lux +++ b/stdlib/source/lux/data/coll/dictionary/unordered.lux @@ -270,12 +270,12 @@ ## So, this test is introduced to detect them. (def: (empty?' node) (All [k v] (-> (Node k v) Bool)) - (case node - (^~ (#Base ..clean-bitmap _)) - true + (`` (case node + (#Base (~~ (static ..clean-bitmap)) _) + true - _ - false)) + _ + false))) (def: (put' level hash key val Hash node) (All [k v] (-> Level Hash-Code k v (Hash k) (Node k v) (Node k v))) diff --git a/stdlib/source/lux/lang/init.lux b/stdlib/source/lux/lang/init.lux index 8d4fdf981..9c909942e 100644 --- a/stdlib/source/lux/lang/init.lux +++ b/stdlib/source/lux/lang/init.lux @@ -1,6 +1,7 @@ (.module: lux - (// [".L" extension] + (// ["//." target] + [".L" extension] (extension [".E" analysis] ## [".E" synthesis] ## [".E" translation] @@ -25,20 +26,23 @@ #.var-counter +0 #.var-bindings (list)}) -(def: #export version Text "0.6.0") - -(def: #export info - Info - {#.target (for {"JVM" "JVM" - "JS" "JS" - "Lua" "Lua" - "Python" "Python" - "Ruby" "Ruby" - "PHP" "PHP" - "Scheme" "Scheme" - "Common Lisp" "Common Lisp"}) - #.version ..version - #.mode #.Build}) +(type: #export Version Text) + +(def: #export version Version "0.6.0") + +(`` (def: #export info + Info + {#.target (for {(~~ (static //target.common-lisp)) //target.common-lisp + (~~ (static //target.js)) //target.js + (~~ (static //target.jvm)) //target.jvm + (~~ (static //target.lua)) //target.lua + (~~ (static //target.php)) //target.php + (~~ (static //target.python)) //target.python + (~~ (static //target.r)) //target.r + (~~ (static //target.ruby)) //target.ruby + (~~ (static //target.scheme)) //target.scheme}) + #.version ..version + #.mode #.Build})) (def: #export (compiler host) (-> Any Lux) @@ -52,10 +56,9 @@ #.expected #.None #.seed +0 #.scope-type-vars (list) - #.extensions (:! Nothing - {#extensionL.analysis analysisE.defaults - #extensionL.synthesis (:!! []) ## synthesisE.defaults - #extensionL.translation (:!! []) ## translationE.defaults - #extensionL.statement (:!! []) ## statementE.defaults - }) - #.host (:! Nothing host)}) + #.extensions {#extensionL.analysis analysisE.defaults + #extensionL.synthesis (:!! []) ## synthesisE.defaults + #extensionL.translation (:!! []) ## translationE.defaults + #extensionL.statement (:!! []) ## statementE.defaults + } + #.host host}) diff --git a/stdlib/source/lux/lang/target.lux b/stdlib/source/lux/lang/target.lux new file mode 100644 index 000000000..ee0eee74d --- /dev/null +++ b/stdlib/source/lux/lang/target.lux @@ -0,0 +1,18 @@ +(.module: + lux) + +(type: #export Target Text) + +(do-template [ ] + [(def: #export Target )] + + [common-lisp "Common Lisp"] + [js "JavaScript"] + [jvm "JVM"] + [lua "Lua"] + [php "PHP"] + [python "Python"] + [r "R"] + [ruby "Ruby"] + [scheme "Scheme"] + ) -- cgit v1.2.3