diff options
Diffstat (limited to 'stdlib/source/lux/macro/syntax/common/reader.lux')
-rw-r--r-- | stdlib/source/lux/macro/syntax/common/reader.lux | 50 |
1 files changed, 26 insertions, 24 deletions
diff --git a/stdlib/source/lux/macro/syntax/common/reader.lux b/stdlib/source/lux/macro/syntax/common/reader.lux index 33ca61b8b..460dabbf6 100644 --- a/stdlib/source/lux/macro/syntax/common/reader.lux +++ b/stdlib/source/lux/macro/syntax/common/reader.lux @@ -2,8 +2,8 @@ lux (lux (control monad ["p" parser]) - (data (coll [list "L/" Functor<List>]) - [ident "Ident/" Eq<Ident>] + (data (coll [list]) + [ident "ident/" Eq<Ident>] [product] [maybe]) [macro] @@ -74,32 +74,34 @@ tail (s;local (list tail) (flat-list^ []))] (wrap (#;Cons head tail)))))) -(def: list-meta^ - (Syntax (List Code)) - (s;form (do p;Monad<Parser> - [_ (s;this (' #lux;ListA))] - (flat-list^ [])))) +(do-template [<name> <type> <tag> <then>] + [(def: <name> + (Syntax <type>) + (<| s;tuple + (p;after s;any) + s;form + (do p;Monad<Parser> + [_ (s;this (' <tag>))] + <then>)))] -(def: text-meta^ - (Syntax Text) - (s;form (do p;Monad<Parser> - [_ (s;this (' #lux;TextA))] - s;text))) + [tuple-meta^ (List Code) #lux;Tuple (flat-list^ [])] + [text-meta^ Text #lux;Text s;text] + ) (def: (find-definition-args meta-data) (-> (List [Ident Code]) (List Text)) - (maybe;default (list) - (case (list;find (|>. product;left (Ident/= ["lux" "func-args"])) meta-data) - (^multi (#;Some [_ value]) - [(p;run (list value) list-meta^) - (#;Right [_ args])] - [(p;run args (p;some text-meta^)) - (#;Right [_ args])]) - (#;Some args) - - _ - #;None) - )) + (<| (maybe;default (list)) + (case (list;find (|>. product;left (ident/= ["lux" "func-args"])) meta-data) + (^multi (#;Some [_ value]) + [(p;run (list value) tuple-meta^) + (#;Right [_ args])] + [(p;run args (p;some text-meta^)) + (#;Right [_ args])]) + (#;Some args) + + _ + #;None) + )) (def: #export (definition compiler) {#;doc "A reader that first macro-expands and then analyses the input Code, to ensure it's a definition."} |