aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/documentation/lux/meta/macro/syntax.lux
diff options
context:
space:
mode:
authorEduardo Julian2022-07-02 16:32:00 -0400
committerEduardo Julian2022-07-02 16:32:00 -0400
commit7e4c9ba2e02f06fa621ffe24bc0ca046536429ef (patch)
tree9e4a4e228d136870f9b706cc804315db6b08d17c /stdlib/source/documentation/lux/meta/macro/syntax.lux
parentb96beb587c11fcfbce86ce2d62351600cf6cad1b (diff)
Moved "lux/macro" to "lux/meta/macro".
Diffstat (limited to 'stdlib/source/documentation/lux/meta/macro/syntax.lux')
-rw-r--r--stdlib/source/documentation/lux/meta/macro/syntax.lux48
1 files changed, 48 insertions, 0 deletions
diff --git a/stdlib/source/documentation/lux/meta/macro/syntax.lux b/stdlib/source/documentation/lux/meta/macro/syntax.lux
new file mode 100644
index 000000000..30dd6b08a
--- /dev/null
+++ b/stdlib/source/documentation/lux/meta/macro/syntax.lux
@@ -0,0 +1,48 @@
+(.require
+ [library
+ [lux (.except char)
+ ["$" documentation]
+ [data
+ [text (.only \n)
+ ["%" \\format (.only format)]]
+ [collection
+ ["[0]" list]]]]]
+ ["[0]" /
+ ["[1][0]" check]
+ ["[1][0]" declaration]
+ ["[1][0]" definition]
+ ["[1][0]" export]
+ ["[1][0]" input]
+ ["[1][0]" type
+ ["[1]/[0]" variable]]]
+ [\\library
+ ["[0]" /]])
+
+(.def .public documentation
+ (.List $.Module)
+ ($.module /._
+ ""
+ [($.documentation /.syntax
+ (format \n "A more advanced way to define macros than 'macro'."
+ \n "The inputs to the macro can be parsed in complex ways through the use of syntax parsers."
+ \n "The macro body is also (implicitly) run in the Meta monad, to save some typing."
+ \n "Also, the compiler state can be accessed through a special binding.")
+ [(def .public object
+ (syntax (_ lux_state [.let [imports (class_imports lux_state)]
+ .let [class_vars (list)]
+ super (opt (super_class_decl^ imports class_vars))
+ interfaces (tuple (some (super_class_decl^ imports class_vars)))
+ constructor_args (constructor_args^ imports class_vars)
+ methods (some (overriden_method_def^ imports))])
+ (let [def_code (all text#composite "anon-class:"
+ (spaced (list (super_class_decl$ (maybe.else object_super_class super))
+ (with_brackets (spaced (list#each super_class_decl$ interfaces)))
+ (with_brackets (spaced (list#each constructor_arg$ constructor_args)))
+ (with_brackets (spaced (list#each (method_def$ id) methods))))))]
+ (in (list (` ((, (code.text def_code)))))))))])]
+ [/check.documentation
+ /declaration.documentation
+ /definition.documentation
+ /export.documentation
+ /input.documentation
+ /type/variable.documentation]))