diff options
Diffstat (limited to 'stdlib/source/library/lux/macro/syntax.lux')
-rw-r--r-- | stdlib/source/library/lux/macro/syntax.lux | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/stdlib/source/library/lux/macro/syntax.lux b/stdlib/source/library/lux/macro/syntax.lux index 9a2e566f0..2d092eaa6 100644 --- a/stdlib/source/library/lux/macro/syntax.lux +++ b/stdlib/source/library/lux/macro/syntax.lux @@ -1,7 +1,6 @@ (.using [library [lux "*" - ["[0]" macro {"+" with_symbols}] ["[0]" meta] [abstract ["[0]" monad {"+" do}]] @@ -20,7 +19,7 @@ ["[0]" int] ["[0]" rev] ["[0]" frac]]]]] - [// + ["[0]" // {"+" with_symbols} ["[0]" code]] ["[0]" / "_" ["[1][0]" export]]) @@ -44,17 +43,18 @@ {.#Item [[x y] pairs']} (partial_list x y (un_paired pairs')))) (def: syntax - (Parser [Code [Text (List Code)] Code]) + (Parser [Code [Text (Maybe Text) (List Code)] Code]) (/export.parser (all <>.and (</>.form (all <>.and </>.local + (<>.maybe </>.local) (</>.tuple (<>.some </>.any)))) </>.any))) (macro: .public (syntax: tokens) (case (</>.result ..syntax tokens) - {try.#Success [export_policy [name args] body]} + {try.#Success [export_policy [name g!state args] body]} (with_symbols [g!tokens g!body g!error] (do [! meta.monad] [vars+parsers (case (list.pairs args) @@ -78,9 +78,14 @@ _ (meta.failure "Syntax pattern expects pairs of bindings and code-parsers.")) + g!state (case g!state + {.#Some g!state} + (in (code.local g!state)) + + {.#None} + (//.symbol "g!state")) this_module meta.current_module_name - .let [g!state (code.symbol ["" "*lux*"]) - error_msg (code.text (macro.wrong_syntax_error [this_module name]))]] + .let [error_msg (code.text (//.wrong_syntax_error [this_module name]))]] (in (list (` (.macro: (~ export_policy) ((~ (code.symbol ["" name])) (~ g!tokens) (~ g!state)) (.case ((~! </>.result) (is ((~! </>.Parser) (Meta (List Code))) @@ -95,4 +100,4 @@ {try.#Failure ((~! text.interposed) (~! text.new_line) (list (~ error_msg) (~ g!error)))}))))))) {try.#Failure error} - (meta.failure (macro.wrong_syntax_error (symbol ..syntax:))))) + (meta.failure (//.wrong_syntax_error (symbol ..syntax:))))) |