diff options
Diffstat (limited to 'stdlib/source/documentation/lux/macro')
10 files changed, 142 insertions, 164 deletions
diff --git a/stdlib/source/documentation/lux/macro/code.lux b/stdlib/source/documentation/lux/macro/code.lux index 707d7f754..df50d5049 100644 --- a/stdlib/source/documentation/lux/macro/code.lux +++ b/stdlib/source/documentation/lux/macro/code.lux @@ -1,7 +1,7 @@ (.require [library [lux (.except char local global) - ["$" documentation (.only documentation:)] + ["$" documentation] [data [text ["%" \\format (.only format)]] @@ -10,20 +10,11 @@ [\\library ["[0]" /]]) -(documentation: /.local - "Produces a local symbol (an symbol with no module prefix).") - -(documentation: /.replaced - "" - [(replaced original substitute ast)]) - (.def .public documentation (.List $.Module) ($.module /._ "" - [..local - ..replaced - ($.default /.bit) + [($.default /.bit) ($.default /.nat) ($.default /.int) ($.default /.rev) @@ -35,5 +26,12 @@ ($.default /.tuple) ($.default /.equivalence) - ($.default /.format)] + ($.default /.format) + + ($.documentation /.local + "Produces a local symbol (an symbol with no module prefix).") + + ($.documentation /.replaced + "" + [(replaced original substitute ast)])] [])) diff --git a/stdlib/source/documentation/lux/macro/local.lux b/stdlib/source/documentation/lux/macro/local.lux index a6256aa92..e71a685fb 100644 --- a/stdlib/source/documentation/lux/macro/local.lux +++ b/stdlib/source/documentation/lux/macro/local.lux @@ -1,7 +1,7 @@ (.require [library [lux (.except char) - ["$" documentation (.only documentation:)] + ["$" documentation] [data [text (.only \n) ["%" \\format (.only format)]] @@ -10,19 +10,18 @@ [\\library ["[0]" /]]) -(documentation: /.push - (format "Installs macros in the compiler-state, with the given names." - \n "Yields code that can be placed either as expression or as declarations." - \n "This code un-installs the macros." - \n "NOTE: Always use this code once to clean-up..") - [(push macros)]) - (.def .public documentation (.List $.Module) ($.module /._ "" - [..push - ($.default /.unknown_module) + [($.default /.unknown_module) ($.default /.cannot_shadow_definition) - ($.default /.unknown_definition)] + ($.default /.unknown_definition) + + ($.documentation /.push + (format "Installs macros in the compiler-state, with the given names." + \n "Yields code that can be placed either as expression or as declarations." + \n "This code un-installs the macros." + \n "NOTE: Always use this code once to clean-up..") + [(push macros)])] [])) diff --git a/stdlib/source/documentation/lux/macro/syntax.lux b/stdlib/source/documentation/lux/macro/syntax.lux index f9d795e37..fc7675a8c 100644 --- a/stdlib/source/documentation/lux/macro/syntax.lux +++ b/stdlib/source/documentation/lux/macro/syntax.lux @@ -1,7 +1,7 @@ (.require [library [lux (.except char) - ["$" documentation (.only documentation:)] + ["$" documentation] [data [text (.only \n) ["%" \\format (.only format)]] @@ -18,30 +18,28 @@ [\\library ["[0]" /]]) -(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)))))))))]) - (.def .public documentation (.List $.Module) ($.module /._ "" - [..syntax] + [($.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 diff --git a/stdlib/source/documentation/lux/macro/syntax/check.lux b/stdlib/source/documentation/lux/macro/syntax/check.lux index b0298cbd3..c96bf0cde 100644 --- a/stdlib/source/documentation/lux/macro/syntax/check.lux +++ b/stdlib/source/documentation/lux/macro/syntax/check.lux @@ -1,7 +1,7 @@ (.require [library [lux (.except char) - ["$" documentation (.only documentation:)] + ["$" documentation] [data [text ["%" \\format (.only format)]] @@ -10,15 +10,14 @@ [\\library ["[0]" /]]) -(documentation: /.Check - "A type annotation for an expression.") - (.def .public documentation (.List $.Module) ($.module /._ "" - [..Check - ($.default /.equivalence) + [($.default /.equivalence) ($.default /.format) - ($.default /.parser)] + ($.default /.parser) + + ($.documentation /.Check + "A type annotation for an expression.")] [])) diff --git a/stdlib/source/documentation/lux/macro/syntax/declaration.lux b/stdlib/source/documentation/lux/macro/syntax/declaration.lux index 9698cc9af..fd9fe1a58 100644 --- a/stdlib/source/documentation/lux/macro/syntax/declaration.lux +++ b/stdlib/source/documentation/lux/macro/syntax/declaration.lux @@ -1,7 +1,7 @@ (.require [library [lux (.except char) - ["$" documentation (.only documentation:)] + ["$" documentation] [data [text ["%" \\format (.only format)]] @@ -10,21 +10,19 @@ [\\library ["[0]" /]]) -(documentation: /.Declaration - "A declaration for either a constant or a function.") - -(documentation: /.parser - "A parser for declaration syntax." - ["Such as:" - quux - (foo bar baz)]) - (.def .public documentation (.List $.Module) ($.module /._ "" - [..Declaration - ..parser - ($.default /.equivalence) - ($.default /.format)] + [($.default /.equivalence) + ($.default /.format) + + ($.documentation /.Declaration + "A declaration for either a constant or a function.") + + ($.documentation /.parser + "A parser for declaration syntax." + ["Such as:" + quux + (foo bar baz)])] [])) diff --git a/stdlib/source/documentation/lux/macro/syntax/definition.lux b/stdlib/source/documentation/lux/macro/syntax/definition.lux index ba2faeb9b..cf4b3225f 100644 --- a/stdlib/source/documentation/lux/macro/syntax/definition.lux +++ b/stdlib/source/documentation/lux/macro/syntax/definition.lux @@ -1,7 +1,7 @@ (.require [library [lux (.except Definition) - ["$" documentation (.only documentation:)] + ["$" documentation] [data [text ["%" \\format (.only format)]] @@ -10,25 +10,22 @@ [\\library ["[0]" /]]) -(documentation: /.Definition - "Syntax for a constant definition.") - -(documentation: /.parser - "A reader that first macro-expands and then analyses the input Code, to ensure it is a definition." - [(parser compiler)]) - -(documentation: /.typed - "Only works for typed definitions." - [(typed compiler)]) - (.def .public documentation (.List $.Module) ($.module /._ "" - [..Definition - ..parser - ..typed - ($.default /.equivalence) + [($.default /.equivalence) ($.default /.lacks_type) - ($.default /.format)] + ($.default /.format) + + ($.documentation /.Definition + "Syntax for a constant definition.") + + ($.documentation /.parser + "A reader that first macro-expands and then analyses the input Code, to ensure it is a definition." + [(parser compiler)]) + + ($.documentation /.typed + "Only works for typed definitions." + [(typed compiler)])] [])) diff --git a/stdlib/source/documentation/lux/macro/syntax/export.lux b/stdlib/source/documentation/lux/macro/syntax/export.lux index 2873623fd..6d23bc8b9 100644 --- a/stdlib/source/documentation/lux/macro/syntax/export.lux +++ b/stdlib/source/documentation/lux/macro/syntax/export.lux @@ -1,7 +1,7 @@ (.require [library [lux (.except char) - ["$" documentation (.only documentation:)] + ["$" documentation] [data [text ["%" \\format (.only format)]] @@ -10,14 +10,13 @@ [\\library ["[0]" /]]) -(documentation: /.parser - "" - [(parser un_exported)]) - (.def .public documentation (.List $.Module) ($.module /._ "Syntax for marking a definition as an export." - [..parser - ($.default /.default_policy)] + [($.default /.default_policy) + + ($.documentation /.parser + "" + [(parser un_exported)])] [])) diff --git a/stdlib/source/documentation/lux/macro/syntax/input.lux b/stdlib/source/documentation/lux/macro/syntax/input.lux index 9e24666c0..77a6b7cac 100644 --- a/stdlib/source/documentation/lux/macro/syntax/input.lux +++ b/stdlib/source/documentation/lux/macro/syntax/input.lux @@ -1,7 +1,7 @@ (.require [library [lux (.except char) - ["$" documentation (.only documentation:)] + ["$" documentation] [data [text ["%" \\format (.only format)]] @@ -10,18 +10,16 @@ [\\library ["[0]" /]]) -(documentation: /.Input - "The common typed-argument syntax used by many macros.") - -(documentation: /.parser - "Parser for the common typed-argument syntax used by many macros.") - (.def .public documentation (.List $.Module) ($.module /._ "" - [..Input - ..parser - ($.default /.equivalence) - ($.default /.format)] + [($.default /.equivalence) + ($.default /.format) + + ($.documentation /.Input + "The common typed-argument syntax used by many macros.") + + ($.documentation /.parser + "Parser for the common typed-argument syntax used by many macros.")] [])) diff --git a/stdlib/source/documentation/lux/macro/syntax/type/variable.lux b/stdlib/source/documentation/lux/macro/syntax/type/variable.lux index 9c88e9856..c29df1817 100644 --- a/stdlib/source/documentation/lux/macro/syntax/type/variable.lux +++ b/stdlib/source/documentation/lux/macro/syntax/type/variable.lux @@ -1,7 +1,7 @@ (.require [library [lux (.except char) - ["$" documentation (.only documentation:)] + ["$" documentation] [data [text ["%" \\format (.only format)]] @@ -10,18 +10,16 @@ [\\library ["[0]" /]]) -(documentation: /.Variable - "A variable's name.") - -(documentation: /.parser - "Parser for the common type variable/parameter used by many macros.") - (.def .public documentation (.List $.Module) ($.module /._ "" - [..Variable - ..parser - ($.default /.equivalence) - ($.default /.format)] + [($.default /.equivalence) + ($.default /.format) + + ($.documentation /.Variable + "A variable's name.") + + ($.documentation /.parser + "Parser for the common type variable/parameter used by many macros.")] [])) diff --git a/stdlib/source/documentation/lux/macro/template.lux b/stdlib/source/documentation/lux/macro/template.lux index 3b4733cce..e75bbfbd9 100644 --- a/stdlib/source/documentation/lux/macro/template.lux +++ b/stdlib/source/documentation/lux/macro/template.lux @@ -1,7 +1,7 @@ (.require [library [lux (.except let symbol) - ["$" documentation (.only documentation:)] + ["$" documentation] [data [text (.only \n) ["%" \\format (.only format)]] @@ -10,62 +10,56 @@ [\\library ["[0]" /]]) -(documentation: /.spliced - "" - [(spliced [a b c d]) - "=>" - a - b - c - d]) +(.def .public documentation + (.List $.Module) + ($.module /._ + "Utilities commonly used while templating." + [($.default /.irregular_arguments) -(documentation: /.amount - "" - [(amount [a b c d]) - "=>" - 4]) + ($.documentation /.spliced + "" + [(spliced [a b c d]) + "=>" + a + b + c + d]) -(documentation: /.with_locals - "Creates names for local bindings aliased by the names you choose." - [(with_locals [my_var] - (let [my_var 123] - (text [my_var]))) - "=>" - "__gensym__my_var506"]) + ($.documentation /.amount + "" + [(amount [a b c d]) + "=>" + 4]) -(documentation: /.text - "A text literal made by concatenating pieces of code." - [(text [#0 123 +456 +789.0 "abc" .def ..ghi]) - "=>" - "#0123+456+789.0abcdefghi"]) + ($.documentation /.with_locals + "Creates names for local bindings aliased by the names you choose." + [(with_locals [my_var] + (let [my_var 123] + (text [my_var]))) + "=>" + "__gensym__my_var506"]) -(documentation: /.symbol - (format "An symbol made by concatenating pieces of code." - \n "The (optional) module part and the short part are specified independently.") - [(symbol ["abc" .def ..ghi]) - "=>" - abcdefghi] - [(symbol [.def] ["abc" .def ..ghi]) - "=>" - .abcdefghi]) + ($.documentation /.text + "A text literal made by concatenating pieces of code." + [(text [#0 123 +456 +789.0 "abc" .def ..ghi]) + "=>" + "#0123+456+789.0abcdefghi"]) -(documentation: /.let - "Lexically-bound templates." - [(let [(!square <root>) - [(* <root> <root>)]] - (def (square root) - (-> Nat Nat) - (!square root)))]) + ($.documentation /.symbol + (format "An symbol made by concatenating pieces of code." + \n "The (optional) module part and the short part are specified independently.") + [(symbol ["abc" .def ..ghi]) + "=>" + abcdefghi] + [(symbol [.def] ["abc" .def ..ghi]) + "=>" + .abcdefghi]) -(.def .public documentation - (.List $.Module) - ($.module /._ - "Utilities commonly used while templating." - [..spliced - ..amount - ..with_locals - ..text - ..symbol - ..let - ($.default /.irregular_arguments)] + ($.documentation /.let + "Lexically-bound templates." + [(let [(!square <root>) + [(* <root> <root>)]] + (def (square root) + (-> Nat Nat) + (!square root)))])] [])) |