diff options
Diffstat (limited to '')
-rw-r--r-- | new-luxc/source/luxc/lang/host/js.lux | 113 |
1 files changed, 0 insertions, 113 deletions
diff --git a/new-luxc/source/luxc/lang/host/js.lux b/new-luxc/source/luxc/lang/host/js.lux deleted file mode 100644 index e8f86ebdd..000000000 --- a/new-luxc/source/luxc/lang/host/js.lux +++ /dev/null @@ -1,113 +0,0 @@ -(.module: - [lux #- or and function] - (lux (data [text] - text/format - (coll [list "list/" Functor<List> Fold<List>])))) - -(type: #export JS Text) - -(type: #export Expression JS) - -(type: #export Statement JS) - -(def: #export (number value) - (-> Frac Expression) - (%f value)) - -(def: #export (string value) - (-> Text Expression) - (%t value)) - -(def: #export (apply func args) - (-> Expression (List Expression) Expression) - (format func "(" (text.join-with "," args) ")")) - -(def: #export (var! name value) - (-> Text (Maybe Expression) Statement) - (case value - #.None - (format "var " name ";") - - (#.Some value) - (format "var " name " = " value ";"))) - -(def: #export (set! name value) - (-> Text Expression Statement) - (format name " = " value ";")) - -(def: #export (if! test then! else!) - (-> Expression Statement Statement Statement) - (format "if(" test ") " - then! - " else " - else!)) - -(def: #export (cond! clauses else!) - (-> (List [Expression Statement]) Statement Statement) - (list/fold (.function (_ [test then!] next!) - (if! test then! next!)) - else! - (list.reverse clauses))) - -(def: #export (block! statements) - (-> (List Statement) Statement) - (format "{" (text.join-with "" statements) "}")) - -(def: #export (while! test body) - (-> Expression (List Statement) Statement) - (format "while(" test ") " (block! body))) - -(def: #export (throw! message) - (-> Expression Statement) - (format "throw Error(" message ");")) - -(def: #export (return! value) - (-> Expression Statement) - (format "return " value ";")) - -(def: #export (function name args body) - (-> Text (List Text) (List Statement) Expression) - (let [args (format "(" (text.join-with ", " args) ")") - function (format "function " name args " " (block! body))] - (format "(" function ")"))) - -(def: #export (? test then else) - (-> Expression Expression Expression Expression) - (format "(" test " ? " then " : " else ")")) - -(def: #export (object fields) - (-> (List [Text Expression]) Expression) - (format "({" - (|> fields - (list/map (.function (_ [key val]) - (format key ": " val))) - (text.join-with ", ")) - "})")) - -(do-template [<name> <op>] - [(def: #export (<name> param subject) - (-> Expression Expression Expression) - (format "(" subject " " <op> " " param ")"))] - - [= "==="] - [< "<"] - [<= "<="] - [> ">"] - [>= ">="] - [+ "+"] - [- "-"] - [* "*"] - [/ "/"] - [% "%"] - ) - -(do-template [<name> <op>] - [(def: #export (<name> param subject) - (-> Expression Expression Expression) - (format "(" param " " <op> " " subject ")"))] - - [or "||"] - [and "&&"] - [bit-or "|"] - [bit-and "&"] - ) |