diff options
Diffstat (limited to 'stdlib/source/lux/macro/syntax.lux')
-rw-r--r-- | stdlib/source/lux/macro/syntax.lux | 40 |
1 files changed, 22 insertions, 18 deletions
diff --git a/stdlib/source/lux/macro/syntax.lux b/stdlib/source/lux/macro/syntax.lux index cb235043f..704f6d245 100644 --- a/stdlib/source/lux/macro/syntax.lux +++ b/stdlib/source/lux/macro/syntax.lux @@ -1,7 +1,7 @@ (.module: [lux (#- nat int rev) [control - ["." monad (#+ do Monad)] + ["." monad (#+ Monad do)] [equivalence (#+ Equivalence)] ["p" parser]] [data @@ -9,12 +9,16 @@ ["." name] ["." maybe] ["." error (#+ Error)] - ["." number] - ["." text ("text/." Monoid<Text>)] + [number + ["." nat] + ["." int] + ["." rev] + ["." frac]] + ["." text ("text/." monoid)] [collection - ["." list ("list/." Functor<List>)]]]] + ["." list ("list/." functor)]]]] ["." // (#+ with-gensyms) - ["." code ("code/." Equivalence<Code>)]]) + ["." code ("code/." equivalence)]]) ## [Utils] (def: (join-pairs pairs) @@ -55,14 +59,14 @@ _ (#error.Failure ($_ text/compose "Cannot parse " <desc> (remaining-inputs tokens))))))] - [ bit Bit #.Bit bit.Equivalence<Bit> "bit"] - [ nat Nat #.Nat number.Equivalence<Nat> "nat"] - [ int Int #.Int number.Equivalence<Int> "int"] - [ rev Rev #.Rev number.Equivalence<Rev> "rev"] - [ frac Frac #.Frac number.Equivalence<Frac> "frac"] - [ text Text #.Text text.Equivalence<Text> "text"] - [identifier Name #.Identifier name.Equivalence<Name> "identifier"] - [ tag Name #.Tag name.Equivalence<Name> "tag"] + [ bit Bit #.Bit bit.equivalence "bit"] + [ nat Nat #.Nat nat.equivalence "nat"] + [ int Int #.Int int.equivalence "int"] + [ rev Rev #.Rev rev.equivalence "rev"] + [ frac Frac #.Frac frac.equivalence "frac"] + [ text Text #.Text text.equivalence "text"] + [identifier Name #.Identifier name.equivalence "identifier"] + [ tag Name #.Tag name.equivalence "tag"] ) (def: #export (this? ast) @@ -190,7 +194,7 @@ {#.doc "Run a syntax parser with the given list of inputs, instead of the real ones."} (All [a] (-> (List Code) (Syntax a) (Syntax a))) (function (_ real) - (do error.Monad<Error> + (do error.monad [value (run inputs syntax)] (wrap [real value])))) @@ -198,7 +202,7 @@ (macro: #export (syntax: tokens) {#.doc (doc "A more advanced way to define macros than 'macro:'." "The inputs to the macro can be parsed in complex ways through the use of syntax parsers." - "The macro body is also (implicitly) run in the Monad<Meta>, to save some typing." + "The macro body is also (implicitly) run in the Meta monad, to save some typing." "Also, the compiler state can be accessed through the *compiler* binding." (syntax: #export (object {#let [imports (class-imports *compiler*)]} {#let [class-vars (list)]} @@ -235,7 +239,7 @@ (case ?parts (#.Some [name args meta body]) (with-gensyms [g!tokens g!body g!error] - (do //.Monad<Meta> + (do //.monad [vars+parsers (monad.map @ (: (-> Code (Meta [Code Code])) (function (_ arg) @@ -265,9 +269,9 @@ (#error.Failure ((~! text.join-with) ": " (list (~ error-msg) (~ g!error))))} ((~! ..run) (~ g!tokens) (: ((~! ..Syntax) (Meta (List Code))) - ((~! do) (~! p.Monad<Parser>) + ((~! do) (~! p.monad) [(~+ (join-pairs vars+parsers))] - ((~' wrap) ((~! do) (~! //.Monad<Meta>) + ((~' wrap) ((~! do) (~! //.monad) [] (~ body))))))))))))) |