diff options
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/library/lux/target/lua.lux | 107 |
1 files changed, 43 insertions, 64 deletions
diff --git a/stdlib/source/library/lux/target/lua.lux b/stdlib/source/library/lux/target/lua.lux index 72324192f..c99893692 100644 --- a/stdlib/source/library/lux/target/lua.lux +++ b/stdlib/source/library/lux/target/lua.lux @@ -1,31 +1,31 @@ (.using - [library - [lux {"-" Location Code Label int if cond function or and not let ^ local comment} - ["@" target] - [abstract - [equivalence {"+" Equivalence}] - [hash {"+" Hash}] - ["[0]" enum]] - [control - [pipe {"+" case> cond> new>}] - [parser - ["<[0]>" code]]] - [data - ["[0]" text - ["%" format {"+" format}]] - [collection - ["[0]" list ("[1]#[0]" functor mix)]]] - [macro - [syntax {"+" syntax:}] - ["[0]" template] - ["[0]" code]] - [math - [number - ["n" nat] - ["i" int] - ["f" frac]]] - [type - abstract]]]) + [library + [lux {"-" Location Code Label int if function or and not let ^ local comment} + ["@" target] + [abstract + [equivalence {"+" Equivalence}] + [hash {"+" Hash}] + ["[0]" enum]] + [control + [pipe {"+" case> cond> new>}] + [parser + ["<[0]>" code]]] + [data + ["[0]" text + ["%" format {"+" format}]] + [collection + ["[0]" list ("[1]#[0]" functor mix)]]] + [macro + [syntax {"+" syntax:}] + ["[0]" template] + ["[0]" code]] + [math + [number + ["n" nat] + ["i" int] + ["f" frac]]] + [type + abstract]]]) ... Added the carriage return for better Windows compatibility. (def: \n+ @@ -89,7 +89,7 @@ Literal (:abstraction "nil")) - (def: .public bool + (def: .public boolean (-> Bit Literal) (|>> (case> #0 "false" #1 "true") @@ -142,7 +142,7 @@ (|>> ..safe (text.enclosed' text.double_quote) :abstraction)) (def: .public multi - (-> (List Expression) Literal) + (-> (List Expression) Expression) (|>> (list#each ..code) (text.interposed ..input_separator) :abstraction)) @@ -159,15 +159,15 @@ (|>> (list#each (.function (_ [key value]) (format key " = " (:representation value)))) (text.interposed ..input_separator) - (text.enclosed ["{" "}"]) + (text.enclosed ["({" "})"]) :abstraction)) (def: .public (item idx array) (-> Expression Expression Access) - (:abstraction (format (:representation array) "[" (:representation idx) "]"))) + (:abstraction (format "(" (:representation array) ")[" (:representation idx) "]"))) (def: .public (the field table) - (-> Text Expression Computation) + (-> Text Expression Access) (:abstraction (format (:representation table) "." field))) (def: .public length @@ -176,7 +176,7 @@ (text.enclosed ["#(" ")"]) :abstraction)) - (def: .public (apply/* args func) + (def: .public (apply args func) (-> (List Expression) Expression Computation) (|> args (list#each ..code) @@ -339,9 +339,9 @@ (text.enclosed ["(" ")"]) :abstraction)) - (template [<name> <code>] + (template [<name> <code> <binding>] [(def: .public (<name> name args body!) - (-> Var (List Var) Statement Statement) + (-> <binding> (List Var) Statement Statement) (:abstraction (format <code> " " (:representation name) (|> args @@ -350,8 +350,8 @@ (..nested (:representation body!)) \n+ "end")))] - [function "function"] - [local_function "local function"] + [function "function" Location] + [local_function "local function" Var] ) (def: .public break @@ -372,13 +372,6 @@ (:abstraction (format "-- " commentary \n+ (:representation on)))) ) -(def: .public (cond clauses else!) - (-> (List [Expression Statement]) Statement Statement) - (list#mix (.function (_ [test then!] next!) - (..if test then! next!)) - else! - (list.reversed clauses))) - (syntax: (arity_inputs [arity <code>.nat]) (in (case arity 0 (.list) @@ -390,37 +383,23 @@ (in (list.repeated arity (` ..Expression)))) (template [<arity> <function>+] - [(with_expansions [<apply> (template.symbol ["apply/" <arity>]) - <inputs> (arity_inputs <arity>) + [(with_expansions [<inputs> (arity_inputs <arity>) <types> (arity_types <arity>) <definitions> (template.spliced <function>+)] - (def: .public (<apply> function <inputs>) - (-> Expression <types> Computation) - (..apply/* (.list <inputs>) function)) - (template [<function>] - [(`` (def: .public (~~ (template.symbol [<function> "/" <arity>])) - (<apply> (..var <function>))))] + [(`` (def: .public ((~~ (template.symbol [<function> "/" <arity>])) <inputs>) + (-> <types> Computation) + (..apply (.list <inputs>) (..var <function>))))] <definitions>))] [1 [["error"] + ["pcall"] ["print"] ["require"] ["type"] ["ipairs"]]] - [2 - [["print"] - ["error"]]] - - [3 - [["print"]]] - - [4 - []] - - [5 - []] + [["error"]]] ) |