aboutsummaryrefslogtreecommitdiff
path: root/stdlib
diff options
context:
space:
mode:
authorEduardo Julian2017-06-26 21:28:00 -0400
committerEduardo Julian2017-06-26 21:28:00 -0400
commit92af791a1a361769c293e50dd5dbd263152e747a (patch)
tree55e5d68c865ff87a4e160564ba1b2ccb3eab471d /stdlib
parent7d4d05bd4949e6281c3e2bdc4dad553da4b33bda (diff)
- Some refactoring.
Diffstat (limited to '')
-rw-r--r--stdlib/source/lux/macro.lux48
-rw-r--r--stdlib/source/lux/macro/syntax/common/reader.lux2
2 files changed, 25 insertions, 25 deletions
diff --git a/stdlib/source/lux/macro.lux b/stdlib/source/lux/macro.lux
index 75ba9d587..c2ea0f04e 100644
--- a/stdlib/source/lux/macro.lux
+++ b/stdlib/source/lux/macro.lux
@@ -272,16 +272,16 @@
_
(:: Monad<Lux> wrap ident)))
-(def: #export (macro-expand-once syntax)
+(def: #export (expand-once syntax)
{#;doc "Given code that requires applying a macro, does it once and returns the result.
Otherwise, returns the code as-is."}
(-> Code (Lux (List Code)))
(case syntax
- [_ (#;Form (#;Cons [[_ (#;Symbol macro-name)] args]))]
+ [_ (#;Form (#;Cons [[_ (#;Symbol name)] args]))]
(do Monad<Lux>
- [macro-name' (normalize macro-name)
- ?macro (find-macro macro-name')]
+ [name' (normalize name)
+ ?macro (find-macro name')]
(case ?macro
(#;Some macro)
(macro args)
@@ -292,21 +292,21 @@
_
(:: Monad<Lux> wrap (list syntax))))
-(def: #export (macro-expand syntax)
+(def: #export (expand syntax)
{#;doc "Given code that requires applying a macro, expands repeatedly until no more direct macro-calls are left.
Otherwise, returns the code as-is."}
(-> Code (Lux (List Code)))
(case syntax
- [_ (#;Form (#;Cons [[_ (#;Symbol macro-name)] args]))]
+ [_ (#;Form (#;Cons [[_ (#;Symbol name)] args]))]
(do Monad<Lux>
- [macro-name' (normalize macro-name)
- ?macro (find-macro macro-name')]
+ [name' (normalize name)
+ ?macro (find-macro name')]
(case ?macro
(#;Some macro)
(do Monad<Lux>
[expansion (macro args)
- expansion' (mapM Monad<Lux> macro-expand expansion)]
+ expansion' (mapM Monad<Lux> expand expansion)]
(wrap (:: Monad<List> join expansion')))
#;None
@@ -315,35 +315,35 @@
_
(:: Monad<Lux> wrap (list syntax))))
-(def: #export (macro-expand-all syntax)
+(def: #export (expand-all syntax)
{#;doc "Expands all macro-calls everywhere recursively, until only primitive/base code remains."}
(-> Code (Lux (List Code)))
(case syntax
- [_ (#;Form (#;Cons [[_ (#;Symbol macro-name)] args]))]
+ [_ (#;Form (#;Cons [[_ (#;Symbol name)] args]))]
(do Monad<Lux>
- [macro-name' (normalize macro-name)
- ?macro (find-macro macro-name')]
+ [name' (normalize name)
+ ?macro (find-macro name')]
(case ?macro
(#;Some macro)
(do Monad<Lux>
[expansion (macro args)
- expansion' (mapM Monad<Lux> macro-expand-all expansion)]
+ expansion' (mapM Monad<Lux> expand-all expansion)]
(wrap (:: Monad<List> join expansion')))
#;None
(do Monad<Lux>
- [parts' (mapM Monad<Lux> macro-expand-all (list& (code;symbol macro-name) args))]
+ [parts' (mapM Monad<Lux> expand-all (list& (code;symbol name) args))]
(wrap (list (code;form (:: Monad<List> join parts')))))))
[_ (#;Form (#;Cons [harg targs]))]
(do Monad<Lux>
- [harg+ (macro-expand-all harg)
- targs+ (mapM Monad<Lux> macro-expand-all targs)]
+ [harg+ (expand-all harg)
+ targs+ (mapM Monad<Lux> expand-all targs)]
(wrap (list (code;form (List/append harg+ (:: Monad<List> join (: (List (List Code)) targs+)))))))
[_ (#;Tuple members)]
(do Monad<Lux>
- [members' (mapM Monad<Lux> macro-expand-all members)]
+ [members' (mapM Monad<Lux> expand-all members)]
(wrap (list (code;tuple (:: Monad<List> join members')))))
_
@@ -391,11 +391,11 @@
_
(fail "Wrong syntax for with-gensyms")))
-(def: #export (macro-expand-1 token)
- {#;doc "Works just like macro-expand, except that it ensures that the output is a single Code token."}
+(def: #export (expand-1 token)
+ {#;doc "Works just like expand, except that it ensures that the output is a single Code token."}
(-> Code (Lux Code))
(do Monad<Lux>
- [token+ (macro-expand token)]
+ [token+ (expand token)]
(case token+
(^ (list token'))
(wrap token')
@@ -646,7 +646,7 @@
_
(fail ($_ Text/append "Wrong syntax for " <desc> "."))))]
- [log-expand macro-expand "log-macro-expand"]
- [log-expand-all macro-expand-all "log-macro-expand-all"]
- [log-expand-once macro-expand-once "log-macro-expand-once"]
+ [log-expand expand "log-expand"]
+ [log-expand-all expand-all "log-expand-all"]
+ [log-expand-once expand-once "log-expand-once"]
)
diff --git a/stdlib/source/lux/macro/syntax/common/reader.lux b/stdlib/source/lux/macro/syntax/common/reader.lux
index 2e14825d5..84d40fb03 100644
--- a/stdlib/source/lux/macro/syntax/common/reader.lux
+++ b/stdlib/source/lux/macro/syntax/common/reader.lux
@@ -106,7 +106,7 @@
(do p;Monad<Parser>
[definition-raw s;any
me-definition-raw (s;on compiler
- (macro;macro-expand-all definition-raw))]
+ (macro;expand-all definition-raw))]
(s;local me-definition-raw
(s;form (do @
[_ (s;this (' lux;_lux_def))