aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/macro.lux
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--stdlib/source/lux/macro.lux27
1 files changed, 20 insertions, 7 deletions
diff --git a/stdlib/source/lux/macro.lux b/stdlib/source/lux/macro.lux
index ead5b366e..a2e17e2d9 100644
--- a/stdlib/source/lux/macro.lux
+++ b/stdlib/source/lux/macro.lux
@@ -384,6 +384,11 @@
_
(fail (text/compose "Code is not a local identifier: " (code.to-text ast)))))
+(def: #export wrong-syntax-error
+ (-> Name Text)
+ (|>> name/encode
+ (text/compose "Wrong syntax for ")))
+
(macro: #export (with-gensyms tokens)
{#.doc (doc "Creates new identifiers and offers them to the body expression."
(syntax: #export (synchronized lock body)
@@ -406,7 +411,7 @@
(~ body))))))
_
- (fail "Wrong syntax for with-gensyms")))
+ (fail (..wrong-syntax-error (name-of ..with-gensyms)))))
(def: #export (expand-1 token)
{#.doc "Works just like expand, except that it ensures that the output is a single Code token."}
@@ -692,7 +697,7 @@
(function (_ compiler)
(#error.Success [compiler (get@ #.type-context compiler)])))
-(do-template [<macro> <func> <desc>]
+(do-template [<macro> <func>]
[(macro: #export (<macro> tokens)
{#.doc (doc "Performs a macro-expansion and logs the resulting code."
"You can either use the resulting code, or omit them."
@@ -716,7 +721,7 @@
(do Monad<Meta>
[cursor ..cursor
output (<func> token)
- #let [_ (log! ($_ text/compose <desc> " @ " (.cursor-description cursor)))
+ #let [_ (log! ($_ text/compose (name/encode (name-of <macro>)) " @ " (.cursor-description cursor)))
_ (list/map (|>> code.to-text log!)
output)
_ (log! "")]]
@@ -725,9 +730,17 @@
output)))
#.None
- (fail ($_ text/compose "Wrong syntax for " <desc> "."))))]
+ (fail (..wrong-syntax-error (name-of <macro>)))))]
- [log-expand! expand "log-expand!"]
- [log-expand-all! expand-all "log-expand-all!"]
- [log-expand-once! expand-once "log-expand-once!"]
+ [log-expand! expand]
+ [log-expand-all! expand-all]
+ [log-expand-once! expand-once]
)
+
+(macro: #export (multi tokens)
+ (case tokens
+ (^ (list [_ (#.Tuple parts)]))
+ (:: Monad<Meta> wrap parts)
+
+ _
+ (fail (..wrong-syntax-error (name-of ..multi)))))