aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/macro/syntax/common/reader.lux
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--stdlib/source/lux/macro/syntax/common/reader.lux51
1 files changed, 26 insertions, 25 deletions
diff --git a/stdlib/source/lux/macro/syntax/common/reader.lux b/stdlib/source/lux/macro/syntax/common/reader.lux
index 19a454ba8..2e14825d5 100644
--- a/stdlib/source/lux/macro/syntax/common/reader.lux
+++ b/stdlib/source/lux/macro/syntax/common/reader.lux
@@ -1,6 +1,7 @@
(;module: {#;doc "Commons syntax readers."}
lux
- (lux (control monad)
+ (lux (control monad
+ ["p" parser])
(data (coll [list "L/" Functor<List>])
[ident "Ident/" Eq<Ident>]
[product])
@@ -15,7 +16,7 @@
#export
#hidden)}
(Syntax (Maybe Export))
- (s;opt (s;alt (s;this (' #export))
+ (p;opt (p;alt (s;this (' #export))
(s;this (' #hidden)))))
## Declarations
@@ -25,62 +26,62 @@
quux
(foo bar baz))}
(Syntax Declaration)
- (s;either (s;seq s;local-symbol
- (:: s;Monad<Syntax> wrap (list)))
- (s;form (s;seq s;local-symbol
- (s;many s;local-symbol)))))
+ (p;either (p;seq s;local-symbol
+ (:: p;Monad<Parser> wrap (list)))
+ (s;form (p;seq s;local-symbol
+ (p;many s;local-symbol)))))
## Annotations
(def: #export annotations
{#;doc "Reader for the common annotations syntax used by def: statements."}
(Syntax Annotations)
- (s;record (s;some (s;seq s;tag s;any))))
+ (s;record (p;some (p;seq s;tag s;any))))
## Definitions
(def: check^
(Syntax [(Maybe Code) Code])
- (s;either (s;form (do s;Monad<Syntax>
+ (p;either (s;form (do p;Monad<Parser>
[_ (s;this (' lux;_lux_:))
type s;any
value s;any]
(wrap [(#;Some type) value])))
- (s;seq (:: s;Monad<Syntax> wrap #;None)
+ (p;seq (:: p;Monad<Parser> wrap #;None)
s;any)))
(def: _definition-anns-tag^
(Syntax Ident)
- (s;tuple (s;seq s;text s;text)))
+ (s;tuple (p;seq s;text s;text)))
(def: (_definition-anns^ _)
(-> Top (Syntax Annotations))
- (s;alt (s;this (' #lux;Nil))
- (s;form (do s;Monad<Syntax>
+ (p;alt (s;this (' #lux;Nil))
+ (s;form (do p;Monad<Parser>
[_ (s;this (' #lux;Cons))
- [head tail] (s;seq (s;tuple (s;seq _definition-anns-tag^ s;any))
+ [head tail] (p;seq (s;tuple (p;seq _definition-anns-tag^ s;any))
(_definition-anns^ []))]
(wrap [head tail])))
))
(def: (flat-list^ _)
(-> Top (Syntax (List Code)))
- (s;either (do s;Monad<Syntax>
+ (p;either (do p;Monad<Parser>
[_ (s;this (' #lux;Nil))]
(wrap (list)))
- (s;form (do s;Monad<Syntax>
+ (s;form (do p;Monad<Parser>
[_ (s;this (' #lux;Cons))
- [head tail] (s;tuple (s;seq s;any s;any))
+ [head tail] (s;tuple (p;seq s;any s;any))
tail (s;local (list tail) (flat-list^ []))]
(wrap (#;Cons head tail))))))
(def: list-meta^
(Syntax (List Code))
- (s;form (do s;Monad<Syntax>
+ (s;form (do p;Monad<Parser>
[_ (s;this (' #lux;ListA))]
(flat-list^ []))))
(def: text-meta^
(Syntax Text)
- (s;form (do s;Monad<Syntax>
+ (s;form (do p;Monad<Parser>
[_ (s;this (' #lux;TextA))]
s;text)))
@@ -89,9 +90,9 @@
(default (list)
(case (list;find (|>. product;left (Ident/= ["lux" "func-args"])) meta-data)
(^multi (#;Some [_ value])
- [(s;run (list value) list-meta^)
+ [(p;run (list value) list-meta^)
(#;Right [_ args])]
- [(s;run args (s;some text-meta^))
+ [(p;run args (p;some text-meta^))
(#;Right [_ args])])
(#;Some args)
@@ -102,7 +103,7 @@
(def: #export (definition compiler)
{#;doc "A reader that first macro-expands and then analyses the input Code, to ensure it's a definition."}
(-> Compiler (Syntax Definition))
- (do s;Monad<Syntax>
+ (do p;Monad<Parser>
[definition-raw s;any
me-definition-raw (s;on compiler
(macro;macro-expand-all definition-raw))]
@@ -124,23 +125,23 @@
(def: #export (typed-definition compiler)
{#;doc "A reader for definitions that ensures the input syntax is typed."}
(-> Compiler (Syntax Definition))
- (do s;Monad<Syntax>
+ (do p;Monad<Parser>
[_definition (definition compiler)
_ (case (get@ #..;definition-type _definition)
(#;Some _)
(wrap [])
#;None
- (s;fail "Typed definition must have a type!")
+ (p;fail "Typed definition must have a type!")
)]
(wrap _definition)))
(def: #export typed-input
{#;doc "Reader for the common typed-argument syntax used by many macros."}
(Syntax [Text Code])
- (s;tuple (s;seq s;local-symbol s;any)))
+ (s;tuple (p;seq s;local-symbol s;any)))
(def: #export type-variables
{#;doc "Reader for the common type var/param used by many macros."}
(Syntax (List Text))
- (s;tuple (s;some s;local-symbol)))
+ (s;tuple (p;some s;local-symbol)))