aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/macro
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--stdlib/source/lux/macro/syntax/common.lux3
-rw-r--r--stdlib/source/lux/macro/syntax/common/reader.lux45
-rw-r--r--stdlib/source/lux/macro/syntax/common/type/variable.lux27
-rw-r--r--stdlib/source/lux/macro/syntax/common/writer.lux4
4 files changed, 27 insertions, 52 deletions
diff --git a/stdlib/source/lux/macro/syntax/common.lux b/stdlib/source/lux/macro/syntax/common.lux
index 6b2a84622..8cfbdeddd 100644
--- a/stdlib/source/lux/macro/syntax/common.lux
+++ b/stdlib/source/lux/macro/syntax/common.lux
@@ -5,6 +5,3 @@
(type: #export Typed_Input
{#input_binding Code
#input_type Code})
-
-(type: #export Type_Var
- Text)
diff --git a/stdlib/source/lux/macro/syntax/common/reader.lux b/stdlib/source/lux/macro/syntax/common/reader.lux
index fcf9ce0d0..cd7ca1dce 100644
--- a/stdlib/source/lux/macro/syntax/common/reader.lux
+++ b/stdlib/source/lux/macro/syntax/common/reader.lux
@@ -14,52 +14,7 @@
["." meta]]
["." //])
-(def: (flat_list^ _)
- (-> Any (Parser (List Code)))
- (p.either (do p.monad
- [_ (s.tag! (name_of #.Nil))]
- (wrap (list)))
- (s.form (do p.monad
- [_ (s.tag! (name_of #.Cons))
- [head tail] (s.tuple (p.and s.any s.any))
- tail (s.local (list tail) (flat_list^ []))]
- (wrap (#.Cons head tail))))))
-
-(template [<name> <type> <tag> <then>]
- [(def: <name>
- (Parser <type>)
- (<| s.tuple
- (p.after s.any)
- s.form
- (do p.monad
- [_ (s.tag! (name_of <tag>))]
- <then>)))]
-
- [tuple_meta^ (List Code) #.Tuple (flat_list^ [])]
- [text_meta^ Text #.Text s.text]
- )
-
-(def: (find_definition_args meta_data)
- (-> (List [Name Code]) (List Text))
- (<| (maybe.default (list))
- (: (Maybe (List Text)))
- (case (list.find (|>> product.left (name\= ["lux" "func-args"])) meta_data)
- (^multi (#.Some [_ value])
- [(p.run tuple_meta^ (list value))
- (#.Right [_ args])]
- [(p.run (p.some text_meta^) args)
- (#.Right [_ args])])
- (#.Some args)
-
- _
- #.None)))
-
(def: #export typed_input
{#.doc "Reader for the common typed-argument syntax used by many macros."}
(Parser //.Typed_Input)
(s.record (p.and s.any s.any)))
-
-(def: #export type_variables
- {#.doc "Reader for the common type var/param used by many macros."}
- (Parser (List Text))
- (p.some s.local_identifier))
diff --git a/stdlib/source/lux/macro/syntax/common/type/variable.lux b/stdlib/source/lux/macro/syntax/common/type/variable.lux
new file mode 100644
index 000000000..22f37a35c
--- /dev/null
+++ b/stdlib/source/lux/macro/syntax/common/type/variable.lux
@@ -0,0 +1,27 @@
+(.module:
+ [lux #*
+ [abstract
+ [equivalence (#+ Equivalence)]]
+ [control
+ [parser
+ ["<.>" code (#+ Parser)]]]
+ [data
+ ["." text]]
+ [macro
+ ["." code]]])
+
+(type: #export Variable
+ Text)
+
+(def: #export equivalence
+ (Equivalence Variable)
+ text.equivalence)
+
+(def: #export format
+ (-> Variable Code)
+ code.local_identifier)
+
+(def: #export parser
+ {#.doc "Parser for the common type variable/parameter used by many macros."}
+ (Parser Variable)
+ <code>.local_identifier)
diff --git a/stdlib/source/lux/macro/syntax/common/writer.lux b/stdlib/source/lux/macro/syntax/common/writer.lux
index 6657e9b9d..18b6556b8 100644
--- a/stdlib/source/lux/macro/syntax/common/writer.lux
+++ b/stdlib/source/lux/macro/syntax/common/writer.lux
@@ -15,7 +15,3 @@
(-> //.Typed_Input Code)
(code.record (list [(get@ #//.input_binding value)
(get@ #//.input_type value)])))
-
-(def: #export type_variables
- (-> (List //.Type_Var) (List Code))
- (list\map code.local_identifier))