diff options
Diffstat (limited to 'stdlib/source/documentation/lux/macro.lux')
-rw-r--r-- | stdlib/source/documentation/lux/macro.lux | 155 |
1 files changed, 72 insertions, 83 deletions
diff --git a/stdlib/source/documentation/lux/macro.lux b/stdlib/source/documentation/lux/macro.lux index e3a659da5..7e6c34963 100644 --- a/stdlib/source/documentation/lux/macro.lux +++ b/stdlib/source/documentation/lux/macro.lux @@ -1,7 +1,7 @@ (.require [library [lux (.except char symbol) - ["$" documentation (.only documentation:)] + ["$" documentation] [data [text (.only \n) ["%" \\format (.only format)]] @@ -15,97 +15,86 @@ [\\library ["[0]" /]]) -(documentation: /.single_expansion - (format "Given code that requires applying a macro, does it once and returns the result." - \n "Otherwise, returns the code as-is.") - [(single_expansion syntax)]) - -(documentation: /.expansion - (format "Given code that requires applying a macro, expands repeatedly until no more direct macro-calls are left." - \n "Otherwise, returns the code as-is.") - [(expansion syntax)]) +(.def .public documentation + (.List $.Module) + ($.module /._ + "" + [($.documentation /.single_expansion + (format "Given code that requires applying a macro, does it once and returns the result." + \n "Otherwise, returns the code as-is.") + [(single_expansion syntax)]) -(documentation: /.full_expansion - "Expands all macro-calls everywhere recursively, until only primitive/base code remains." - [(full_expansion syntax)]) + ($.documentation /.expansion + (format "Given code that requires applying a macro, expands repeatedly until no more direct macro-calls are left." + \n "Otherwise, returns the code as-is.") + [(expansion syntax)]) -(documentation: /.symbol - (format "Generates a unique name as a Code node (ready to be used in code templates)." - \n "A prefix can be given (or just be empty text) to better identify the code for debugging purposes.") - [(symbol prefix)]) + ($.documentation /.full_expansion + "Expands all macro-calls everywhere recursively, until only primitive/base code remains." + [(full_expansion syntax)]) -(documentation: /.wrong_syntax_error - "A generic error message for macro syntax failures.") + ($.documentation /.symbol + (format "Generates a unique name as a Code node (ready to be used in code templates)." + \n "A prefix can be given (or just be empty text) to better identify the code for debugging purposes.") + [(symbol prefix)]) -(documentation: /.with_symbols - "Creates new symbols and offers them to the body expression." - [(def synchronized - (syntax (_ [lock any - body any]) - (with_symbols [g!lock g!body g!_] - (in (list (` (let [(~ g!lock) (~ lock) - (~ g!_) ("jvm monitorenter" (~ g!lock)) - (~ g!body) (~ body) - (~ g!_) ("jvm monitorexit" (~ g!lock))] - (~ g!body))))))))]) + ($.documentation /.wrong_syntax_error + "A generic error message for macro syntax failures.") -(documentation: /.one_expansion - "Works just like expand, except that it ensures that the output is a single Code token." - [(one_expansion token)]) + ($.documentation /.with_symbols + "Creates new symbols and offers them to the body expression." + [(def synchronized + (syntax (_ [lock any + body any]) + (with_symbols [g!lock g!body g!_] + (in (list (` (let [(~ g!lock) (~ lock) + (~ g!_) ("jvm monitorenter" (~ g!lock)) + (~ g!body) (~ body) + (~ g!_) ("jvm monitorexit" (~ g!lock))] + (~ g!body))))))))]) -(documentation: /.log_single_expansion! - (format "Performs a macro-expansion and logs the resulting code." - \n "You can either use the resulting code, or omit them." - \n "By omitting them, this macro produces nothing (just like the lux.comment macro).") - [(log_single_expansion! - (def (foo bar baz) - (-> Int Int Int) - (int.+ bar baz))) - (log_single_expansion! "omit" - (def (foo bar baz) - (-> Int Int Int) - (int.+ bar baz)))]) + ($.documentation /.one_expansion + "Works just like expand, except that it ensures that the output is a single Code token." + [(one_expansion token)]) -(documentation: /.log_expansion! - (format "Performs a macro-expansion and logs the resulting code." - \n "You can either use the resulting code, or omit them." - \n "By omitting them, this macro produces nothing (just like the lux.comment macro).") - [(log_expansion! - (def (foo bar baz) - (-> Int Int Int) - (int.+ bar baz))) - (log_expansion! "omit" - (def (foo bar baz) - (-> Int Int Int) - (int.+ bar baz)))]) + ($.documentation /.log_single_expansion! + (format "Performs a macro-expansion and logs the resulting code." + \n "You can either use the resulting code, or omit them." + \n "By omitting them, this macro produces nothing (just like the lux.comment macro).") + [(log_single_expansion! + (def (foo bar baz) + (-> Int Int Int) + (int.+ bar baz))) + (log_single_expansion! "omit" + (def (foo bar baz) + (-> Int Int Int) + (int.+ bar baz)))]) -(documentation: /.log_full_expansion! - (format "Performs a macro-expansion and logs the resulting code." - \n "You can either use the resulting code, or omit them." - \n "By omitting them, this macro produces nothing (just like the lux.comment macro).") - [(log_full_expansion! - (def (foo bar baz) - (-> Int Int Int) - (int.+ bar baz))) - (log_full_expansion! "omit" - (def (foo bar baz) - (-> Int Int Int) - (int.+ bar baz)))]) + ($.documentation /.log_expansion! + (format "Performs a macro-expansion and logs the resulting code." + \n "You can either use the resulting code, or omit them." + \n "By omitting them, this macro produces nothing (just like the lux.comment macro).") + [(log_expansion! + (def (foo bar baz) + (-> Int Int Int) + (int.+ bar baz))) + (log_expansion! "omit" + (def (foo bar baz) + (-> Int Int Int) + (int.+ bar baz)))]) -(.def .public documentation - (.List $.Module) - ($.module /._ - "" - [..single_expansion - ..expansion - ..full_expansion - ..symbol - ..wrong_syntax_error - ..with_symbols - ..one_expansion - ..log_single_expansion! - ..log_expansion! - ..log_full_expansion!] + ($.documentation /.log_full_expansion! + (format "Performs a macro-expansion and logs the resulting code." + \n "You can either use the resulting code, or omit them." + \n "By omitting them, this macro produces nothing (just like the lux.comment macro).") + [(log_full_expansion! + (def (foo bar baz) + (-> Int Int Int) + (int.+ bar baz))) + (log_full_expansion! "omit" + (def (foo bar baz) + (-> Int Int Int) + (int.+ bar baz)))])] [/code.documentation /local.documentation /syntax.documentation |