aboutsummaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorEduardo Julian2015-09-06 02:11:23 -0400
committerEduardo Julian2015-09-06 02:11:23 -0400
commit0f596a44ffc486b7e0369eebd3b79d22315e8814 (patch)
tree616c6f55fe88f27048a1964f855849955f3201e5 /source
parent455018ec68f2c127db489048351bc48f3982fe23 (diff)
- Removed the (unnecessary) lux/meta/macro module.
Diffstat (limited to 'source')
-rw-r--r--source/lux.lux122
-rw-r--r--source/lux/codata/lazy.lux3
-rw-r--r--source/lux/codata/stream.lux1
-rw-r--r--source/lux/control/comonad.lux3
-rw-r--r--source/lux/control/monad.lux3
-rw-r--r--source/lux/data/io.lux9
-rw-r--r--source/lux/data/list.lux3
-rw-r--r--source/lux/data/maybe.lux6
-rw-r--r--source/lux/data/text.lux3
-rw-r--r--source/lux/meta/lux.lux3
-rw-r--r--source/lux/meta/macro.lux28
-rw-r--r--source/lux/meta/syntax.lux3
-rw-r--r--source/program.lux1
13 files changed, 90 insertions, 98 deletions
diff --git a/source/lux.lux b/source/lux.lux
index 164dea835..76ca9517f 100644
--- a/source/lux.lux
+++ b/source/lux.lux
@@ -621,7 +621,7 @@
)))
(_lux_declare-macro def'')
-(def'' (defmacro tokens)
+(def'' (defmacro' tokens)
Macro
(_lux_case tokens
(#Cons [[_ (#FormS (#Cons [name args]))] (#Cons [body #Nil])])
@@ -646,13 +646,13 @@
#Nil])]))
_
- (fail "Wrong syntax for defmacro")))
-(_lux_declare-macro defmacro)
+ (fail "Wrong syntax for defmacro'")))
+(_lux_declare-macro defmacro')
-(defmacro #export (comment tokens)
+(defmacro' #export (comment tokens)
(return #Nil))
-(defmacro ($' tokens)
+(defmacro' ($' tokens)
(_lux_case tokens
(#Cons x #Nil)
(return tokens)
@@ -817,7 +817,7 @@
(#Cons x xs')
(foldL f (f init x) xs')))
-(defmacro #export (All tokens)
+(defmacro' #export (All tokens)
(let'' [self-name tokens] (_lux_: (#TupleT (#Cons Text (#Cons ASTList #Nil)))
(_lux_case tokens
(#Cons [_ (#SymbolS "" self-name)] tokens)
@@ -844,7 +844,7 @@
(fail "Wrong syntax for All"))
))
-(defmacro #export (Ex tokens)
+(defmacro' #export (Ex tokens)
(let'' [self-name tokens] (_lux_: (#TupleT (#Cons Text (#Cons ASTList #Nil)))
(_lux_case tokens
(#Cons [_ (#SymbolS "" self-name)] tokens)
@@ -877,7 +877,7 @@
#Nil
list))
-(defmacro #export (-> tokens)
+(defmacro' #export (-> tokens)
(_lux_case (reverse tokens)
(#Cons output inputs)
(return (#Cons (foldL (_lux_: (#LambdaT AST (#LambdaT AST AST))
@@ -889,7 +889,7 @@
_
(fail "Wrong syntax for ->")))
-(defmacro (@list xs)
+(defmacro' (@list xs)
(return (#Cons (foldL (lambda'' [tail head]
(form$ (#Cons (tag$ ["lux" "Cons"])
(#Cons (tuple$ (#Cons [head (#Cons [tail #Nil])]))
@@ -898,7 +898,7 @@
(reverse xs))
#Nil)))
-(defmacro (@list& xs)
+(defmacro' (@list& xs)
(_lux_case (reverse xs)
(#Cons last init)
(return (@list (foldL (lambda'' [tail head]
@@ -910,7 +910,7 @@
_
(fail "Wrong syntax for @list&")))
-(defmacro #export (^ tokens)
+(defmacro' #export (^ tokens)
(_lux_case tokens
(#Cons [_ (#SymbolS "" class-name)] #Nil)
(return (@list (form$ (@list (tag$ ["lux" "DataT"]) (text$ class-name)))))
@@ -918,13 +918,13 @@
_
(fail "Wrong syntax for ^")))
-(defmacro #export (, tokens)
+(defmacro' #export (, tokens)
(return (@list (form$ (@list (tag$ ["lux" "TupleT"])
(foldL (lambda'' [tail head] (form$ (@list (tag$ ["lux" "Cons"]) head tail)))
(tag$ ["lux" "Nil"])
(reverse tokens)))))))
-(defmacro (lambda' tokens)
+(defmacro' (lambda' tokens)
(let'' [name tokens'] (_lux_: (, Text ($' List AST))
(_lux_case tokens
(#Cons [[_ (#SymbolS ["" name])] tokens'])
@@ -953,7 +953,7 @@
_
(fail "Wrong syntax for lambda'"))))
-(defmacro (def''' tokens)
+(defmacro' (def''' tokens)
(_lux_case tokens
(#Cons [[_ (#TagS ["" "export"])]
(#Cons [[_ (#FormS (#Cons [name args]))]
@@ -1005,7 +1005,7 @@
_
#Nil))
-(defmacro (let' tokens)
+(defmacro' (let' tokens)
(_lux_case tokens
(#Cons [[_ (#TupleS bindings)] (#Cons [body #Nil])])
(return (@list (foldL (_lux_: (-> AST (, AST AST)
@@ -1064,7 +1064,7 @@
#Nil
ys))
-(defmacro #export ($ tokens)
+(defmacro' #export ($ tokens)
(_lux_case tokens
(#Cons op (#Cons init args))
(return (@list (foldL (lambda' [a1 a2] (form$ (@list op a1 a2)))
@@ -1125,7 +1125,7 @@
(#Right state' a)
(f a state'))))})
-(defmacro (do tokens)
+(defmacro' (do tokens)
(_lux_case tokens
(#Cons monad (#Cons [_ (#TupleS bindings)] (#Cons body #Nil)))
(let' [g!wrap (symbol$ ["" "wrap"])
@@ -1171,7 +1171,7 @@
(wrap (#Cons y ys)))
)))
-(defmacro #export (if tokens)
+(defmacro' #export (if tokens)
(_lux_case tokens
(#Cons test (#Cons then (#Cons else #Nil)))
(return (@list (form$ (@list (symbol$ ["" "_lux_case"]) test
@@ -1279,19 +1279,19 @@
(-> Bool Text AST ($' Lux AST))
(_lux_case (_lux_: (, Bool AST) [replace? token])
[_ [_ (#BoolS value)]]
- (return (wrap-meta (form$ (@list (tag$ ["lux" "BoolS"]) (_meta (#BoolS value))))))
+ (return (wrap-meta (form$ (@list (tag$ ["lux" "BoolS"]) (bool$ value)))))
[_ [_ (#IntS value)]]
- (return (wrap-meta (form$ (@list (tag$ ["lux" "IntS"]) (_meta (#IntS value))))))
+ (return (wrap-meta (form$ (@list (tag$ ["lux" "IntS"]) (int$ value)))))
[_ [_ (#RealS value)]]
- (return (wrap-meta (form$ (@list (tag$ ["lux" "RealS"]) (_meta (#RealS value))))))
+ (return (wrap-meta (form$ (@list (tag$ ["lux" "RealS"]) (real$ value)))))
[_ [_ (#CharS value)]]
- (return (wrap-meta (form$ (@list (tag$ ["lux" "CharS"]) (_meta (#CharS value))))))
+ (return (wrap-meta (form$ (@list (tag$ ["lux" "CharS"]) (char$ value)))))
[_ [_ (#TextS value)]]
- (return (wrap-meta (form$ (@list (tag$ ["lux" "TextS"]) (_meta (#TextS value))))))
+ (return (wrap-meta (form$ (@list (tag$ ["lux" "TextS"]) (text$ value)))))
[_ [_ (#TagS [module name])]]
(let' [module' (_lux_case module
@@ -1353,31 +1353,31 @@
#Nil
(#Left "Can't get the module name without a module!")
- (#Cons [{#name module-name #inner-closures _ #locals _ #closure _} _])
+ (#Cons {#name module-name #inner-closures _ #locals _ #closure _} _)
(#Right [state module-name]))))
-(defmacro #export (` tokens)
+(defmacro' #export (` tokens)
(_lux_case tokens
(#Cons template #Nil)
(do Lux/Monad
[current-module get-module-name
=template (untemplate true current-module template)]
- (wrap (@list =template)))
+ (wrap (@list (form$ (@list (symbol$ ["" "_lux_:"]) (symbol$ ["lux" "AST"]) =template)))))
_
(fail "Wrong syntax for `")))
-(defmacro #export (' tokens)
+(defmacro' #export (' tokens)
(_lux_case tokens
(#Cons template #Nil)
(do Lux/Monad
[=template (untemplate false "" template)]
- (wrap (@list =template)))
+ (wrap (@list (form$ (@list (symbol$ ["" "_lux_:"]) (symbol$ ["lux" "AST"]) =template)))))
_
(fail "Wrong syntax for '")))
-(defmacro #export (|> tokens)
+(defmacro' #export (|> tokens)
(_lux_case tokens
(#Cons [init apps])
(return (@list (foldL (_lux_: (-> AST AST AST)
@@ -1467,7 +1467,7 @@
(#Cons [x xs'])
(list:++ (f x) (join-map f xs'))))
-(defmacro #export (do-template tokens)
+(defmacro' #export (do-template tokens)
(_lux_case tokens
(#Cons [[_ (#TupleS bindings)] (#Cons [[_ (#TupleS templates)] data])])
(_lux_case (_lux_: (, ($' Maybe ($' List Text)) ($' Maybe ($' List ($' List AST))))
@@ -1688,7 +1688,7 @@
_
type))
-(defmacro #export (@type tokens)
+(defmacro' #export (@type tokens)
(_lux_case tokens
(#Cons type #Nil)
(do Lux/Monad
@@ -1703,7 +1703,7 @@
_
(fail "Wrong syntax for @type")))
-(defmacro #export (: tokens)
+(defmacro' #export (: tokens)
(_lux_case tokens
(#Cons type (#Cons value #Nil))
(return (@list (` (;_lux_: (@type (~ type)) (~ value)))))
@@ -1711,7 +1711,7 @@
_
(fail "Wrong syntax for :")))
-(defmacro #export (:! tokens)
+(defmacro' #export (:! tokens)
(_lux_case tokens
(#Cons type (#Cons value #Nil))
(return (@list (` (;_lux_:! (@type (~ type)) (~ value)))))
@@ -1791,7 +1791,7 @@
#cursor cursor}
(symbol$ ["" ($ text:++ "__gensym__" prefix (->text seed))]))))
-(defmacro #export (Rec tokens)
+(defmacro' #export (Rec tokens)
(_lux_case tokens
(#Cons [_ (#SymbolS "" name)] (#Cons body #Nil))
(let' [body' (replace-syntax (@list [name (` (#AppT (~ (make-bound 0)) (~ (make-bound 1))))]) body)]
@@ -1800,7 +1800,7 @@
_
(fail "Wrong syntax for Rec")))
-(defmacro #export (deftype tokens)
+(defmacro' #export (deftype tokens)
(let' [[export? tokens'] (: (, Bool (List AST))
(_lux_case tokens
(#Cons [_ (#TagS "" "export")] tokens')
@@ -1872,7 +1872,7 @@
(fail "Wrong syntax for deftype"))
))
-(defmacro #export (exec tokens)
+(defmacro' #export (exec tokens)
(_lux_case (reverse tokens)
(#Cons value actions)
(let' [dummy (symbol$ ["" ""])]
@@ -1884,7 +1884,7 @@
_
(fail "Wrong syntax for exec")))
-(defmacro (def' tokens)
+(defmacro' (def' tokens)
(let' [[export? tokens'] (: (, Bool (List AST))
(_lux_case tokens
(#Cons [_ (#TagS "" "export")] tokens')
@@ -1979,7 +1979,7 @@
(let' [[left right] pair]
(@list left right)))
-(defmacro #export (case tokens)
+(defmacro' #export (case tokens)
(_lux_case tokens
(#Cons value branches)
(do Lux/Monad
@@ -2007,7 +2007,7 @@
_
(fail "Wrong syntax for case")))
-(defmacro #export (\ tokens)
+(defmacro' #export (\ tokens)
(case tokens
(#Cons body (#Cons pattern #Nil))
(do Lux/Monad
@@ -2023,7 +2023,7 @@
_
(fail "Wrong syntax for \\")))
-(defmacro #export (\or tokens)
+(defmacro' #export (\or tokens)
(case tokens
(#Cons body patterns)
(case patterns
@@ -2048,7 +2048,7 @@
_
false))
-(defmacro #export (let tokens)
+(defmacro' #export (let tokens)
(case tokens
(\ (@list [_ (#TupleS bindings)] body))
(if (multiple? 2 (length bindings))
@@ -2067,7 +2067,7 @@
_
(fail "Wrong syntax for let")))
-(defmacro #export (lambda tokens)
+(defmacro' #export (lambda tokens)
(case (: (Maybe (, Ident AST (List AST) AST))
(case tokens
(\ (@list [_ (#TupleS (#Cons head tail))] body))
@@ -2086,7 +2086,7 @@
(if (symbol? arg)
(` (;_lux_lambda (~ g!blank) (~ arg) (~ body')))
(` (;_lux_lambda (~ g!blank) (~ g!blank)
- (case (~ g!blank) (~ arg) (~ body')))))))
+ (case (~ g!blank) (~ arg) (~ body')))))))
body
(reverse tail)))]
(return (@list (if (symbol? head)
@@ -2096,7 +2096,7 @@
#None
(fail "Wrong syntax for lambda")))
-(defmacro #export (def tokens)
+(defmacro' #export (def tokens)
(let [[export? tokens'] (: (, Bool (List AST))
(case tokens
(#Cons [_ (#TagS "" "export")] tokens')
@@ -2144,6 +2144,40 @@
#None
(fail "Wrong syntax for def"))))
+(defmacro' #export (defmacro tokens)
+ (let [[exported? tokens] (: (, Bool (List AST))
+ (case tokens
+ (\ (@list& [_ (#TagS ["" "export"])] tokens'))
+ [true tokens']
+
+ _
+ [false tokens]))
+ name+args+body?? (: (Maybe (, Ident (List AST) AST))
+ (case tokens
+ (\ (@list [_ (#;FormS (@list& [_ (#SymbolS name)] args))] body))
+ (#Some [name args body])
+
+ (\ (@list [_ (#;SymbolS name)] body))
+ (#Some [name #Nil body])
+
+ _
+ #None))]
+ (case name+args+body??
+ (#Some [name args body])
+ (let [name (symbol$ name)
+ decls (list:++ (: (List AST) (if exported? (@list (` (;_lux_export (~ name)))) #;Nil))
+ (: (List AST) (@list (` (;;_lux_declare-macro (~ name))))))
+ def-sig (: AST
+ (case args
+ #;Nil name
+ _ (` ((~ name) (~@ args)))))]
+ (return (@list& (` (;;def (~ def-sig) ;;Macro (~ body)))
+ decls)))
+
+
+ #None
+ (fail "Wrong syntax for defmacro"))))
+
(defmacro #export (defsig tokens)
(let [[export? tokens'] (: (, Bool (List AST))
(case tokens
diff --git a/source/lux/codata/lazy.lux b/source/lux/codata/lazy.lux
index 542bb9922..37fbbac64 100644
--- a/source/lux/codata/lazy.lux
+++ b/source/lux/codata/lazy.lux
@@ -4,8 +4,7 @@
## You can obtain one at http://mozilla.org/MPL/2.0/.
(;import lux
- (lux (meta macro
- ast)
+ (lux (meta ast)
(control (functor #as F #refer #all)
(monad #as M #refer #all))
(data list))
diff --git a/source/lux/codata/stream.lux b/source/lux/codata/stream.lux
index a25a19b5f..e2464248c 100644
--- a/source/lux/codata/stream.lux
+++ b/source/lux/codata/stream.lux
@@ -8,7 +8,6 @@
(monad #as M #refer #all)
(comonad #as CM #refer #all))
(meta lux
- macro
syntax)
(data (list #as l #refer (#only @list @list& List/Monad))
(number (int #open ("i" Int/Number Int/Ord)))
diff --git a/source/lux/control/comonad.lux b/source/lux/control/comonad.lux
index 8e12c24c0..32e7c64c1 100644
--- a/source/lux/control/comonad.lux
+++ b/source/lux/control/comonad.lux
@@ -5,8 +5,7 @@
(;import lux
(../functor #as F)
- lux/data/list
- lux/meta/macro)
+ lux/data/list)
## [Signatures]
(defsig #export (CoMonad w)
diff --git a/source/lux/control/monad.lux b/source/lux/control/monad.lux
index b286545a7..883875a03 100644
--- a/source/lux/control/monad.lux
+++ b/source/lux/control/monad.lux
@@ -5,8 +5,7 @@
(;import lux
(.. (functor #as F)
- (monoid #as M))
- (lux/meta macro))
+ (monoid #as M)))
## [Utils]
(def (foldL f init xs)
diff --git a/source/lux/data/io.lux b/source/lux/data/io.lux
index 4919d2edd..a0bfda3e0 100644
--- a/source/lux/data/io.lux
+++ b/source/lux/data/io.lux
@@ -4,12 +4,9 @@
## You can obtain one at http://mozilla.org/MPL/2.0/.
(;import lux
- (lux (meta macro
- ast)
- (control (functor #as F)
+ (lux (control (functor #as F)
(monad #as M)))
- (.. list
- (text #as T #open ("text:" Text/Monoid))))
+ (.. list))
## [Types]
(deftype #export (IO a)
@@ -19,7 +16,7 @@
(defmacro #export (@io tokens state)
(case tokens
(\ (@list value))
- (let [blank (symbol$ ["" ""])]
+ (let [blank (: AST [["" -1 -1] (#;SymbolS ["" ""])])]
(#;Right [state (@list (` (;_lux_lambda (~ blank) (~ blank) (~ value))))]))
_
diff --git a/source/lux/data/list.lux b/source/lux/data/list.lux
index b2049d419..0da0b3ecb 100644
--- a/source/lux/data/list.lux
+++ b/source/lux/data/list.lux
@@ -11,8 +11,7 @@
(ord #as O)
(fold #as f))
(data (number (int #open ("i" Int/Number Int/Ord)))
- bool)
- meta/macro))
+ bool)))
## [Types]
## (deftype (List a)
diff --git a/source/lux/data/maybe.lux b/source/lux/data/maybe.lux
index 2db3d768d..1303270a7 100644
--- a/source/lux/data/maybe.lux
+++ b/source/lux/data/maybe.lux
@@ -4,11 +4,9 @@
## You can obtain one at http://mozilla.org/MPL/2.0/.
(;import lux
- (lux (meta macro)
- (control (monoid #as m #refer #all)
+ (lux (control (monoid #as m #refer #all)
(functor #as F #refer #all)
- (monad #as M #refer #all)))
- (.. list))
+ (monad #as M #refer #all))))
## [Types]
## (deftype (Maybe a)
diff --git a/source/lux/data/text.lux b/source/lux/data/text.lux
index f701f6079..3fad6c7aa 100644
--- a/source/lux/data/text.lux
+++ b/source/lux/data/text.lux
@@ -4,8 +4,7 @@
## You can obtain one at http://mozilla.org/MPL/2.0/.
(;import lux
- (lux (meta macro)
- (control (monoid #as m)
+ (lux (control (monoid #as m)
(eq #as E)
(ord #as O)
(show #as S)
diff --git a/source/lux/meta/lux.lux b/source/lux/meta/lux.lux
index dd14e708d..a34f92253 100644
--- a/source/lux/meta/lux.lux
+++ b/source/lux/meta/lux.lux
@@ -4,8 +4,7 @@
## You can obtain one at http://mozilla.org/MPL/2.0/.
(;import lux
- (.. macro
- ast)
+ (.. ast)
(lux/control (monoid #as m)
(functor #as F)
(monad #as M #refer (#only do))
diff --git a/source/lux/meta/macro.lux b/source/lux/meta/macro.lux
deleted file mode 100644
index f554f45b4..000000000
--- a/source/lux/meta/macro.lux
+++ /dev/null
@@ -1,28 +0,0 @@
-## Copyright (c) Eduardo Julian. All rights reserved.
-## This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
-## If a copy of the MPL was not distributed with this file,
-## You can obtain one at http://mozilla.org/MPL/2.0/.
-
-(;import lux)
-
-## [Syntax]
-(def #export (defmacro tokens state)
- Macro
- (case tokens
- (#;Cons [[_ (#;FormS (#;Cons [name args]))] (#;Cons [body #;Nil])])
- (#;Right [state (#;Cons [(` ((~ [["" -1 -1] (#;SymbolS ["lux" "def"])]) ((~ name) (~@ args))
- (~ [["" -1 -1] (#;SymbolS ["lux" "Macro"])])
- (~ body)))
- (#;Cons [(` ((~ [["" -1 -1] (#;SymbolS ["" "_lux_declare-macro"])]) (~ name)))
- #;Nil])])])
-
- (#;Cons [[_ (#;TagS ["" "export"])] (#;Cons [[_ (#;FormS (#;Cons [name args]))] (#;Cons [body #;Nil])])])
- (#;Right [state (#;Cons [(` ((~ [["" -1 -1] (#;SymbolS ["lux" "def"])]) (~ [["" -1 -1] (#;TagS ["" "export"])]) ((~ name) (~@ args))
- (~ [["" -1 -1] (#;SymbolS ["lux" "Macro"])])
- (~ body)))
- (#;Cons [(` ((~ [["" -1 -1] (#;SymbolS ["" "_lux_declare-macro"])]) (~ name)))
- #;Nil])])])
-
- _
- (#;Left "Wrong syntax for defmacro")))
-(_lux_declare-macro defmacro)
diff --git a/source/lux/meta/syntax.lux b/source/lux/meta/syntax.lux
index 3bc3196e2..3d62bba2e 100644
--- a/source/lux/meta/syntax.lux
+++ b/source/lux/meta/syntax.lux
@@ -4,8 +4,7 @@
## You can obtain one at http://mozilla.org/MPL/2.0/.
(;import lux
- (.. (macro #as m #refer #all)
- ast
+ (.. ast
(lux #as l #refer (#only Lux/Monad gensym)))
(lux (control (functor #as F)
(monad #as M #refer (#only do))
diff --git a/source/program.lux b/source/program.lux
index 140710a4a..fa8b3a055 100644
--- a/source/program.lux
+++ b/source/program.lux
@@ -37,7 +37,6 @@
io)
(meta ast
lux
- macro
syntax
type)
math