From 834ed92e323fd274c2da08c82a7d8785663e10be Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Mon, 30 Aug 2021 04:21:53 -0400 Subject: Better tagged type documentation + lexer fix. --- stdlib/source/documentation/lux/control/maybe.lux | 2 +- .../documentation/lux/data/collection/list.lux | 2 +- stdlib/source/library/lux/documentation.lux | 38 +++++++++++++--------- stdlib/source/library/lux/meta.lux | 9 +++-- .../lux/tool/compiler/language/lux/syntax.lux | 2 +- 5 files changed, 31 insertions(+), 22 deletions(-) diff --git a/stdlib/source/documentation/lux/control/maybe.lux b/stdlib/source/documentation/lux/control/maybe.lux index dabdcde5e..f096b1d40 100644 --- a/stdlib/source/documentation/lux/control/maybe.lux +++ b/stdlib/source/documentation/lux/control/maybe.lux @@ -35,7 +35,7 @@ "Can be used as a guard in (co)monadic be/do expressions." [(do monad [value (do_something 1 2 3) - /.when (passes_test? value)] + .when (passes_test? value)] (do_something_else 4 5 6))]) (.def: .public documentation diff --git a/stdlib/source/documentation/lux/data/collection/list.lux b/stdlib/source/documentation/lux/data/collection/list.lux index f5dda38bc..d11cc2605 100644 --- a/stdlib/source/documentation/lux/data/collection/list.lux +++ b/stdlib/source/documentation/lux/data/collection/list.lux @@ -174,7 +174,7 @@ "Can be used as a guard in (co)monadic be/do expressions." [(do monad [value (do_something 1 2 3) - /.when (passes_test? value)] + .when (passes_test? value)] (do_something_else 4 5 6))]) (.def: .public documentation diff --git a/stdlib/source/library/lux/documentation.lux b/stdlib/source/library/lux/documentation.lux index 5de44d483..1c5150f41 100644 --- a/stdlib/source/library/lux/documentation.lux +++ b/stdlib/source/library/lux/documentation.lux @@ -97,18 +97,22 @@ (def: (code_documentation expected_module old_location reference_column example) (-> Text Location Nat Code [Location Text]) (case example - [new_location (#.Identifier [module short])] - (let [documentation (cond (text\= expected_module module) - short - - (text\= .prelude_module module) - (format "." short) - - ... else - (%.name [module short]))] - [(revised@ #.column (n.+ (text.size documentation)) new_location) - (format (padding reference_column old_location new_location) - documentation)]) + (^template [ ] + [[new_location ( [module short])] + (let [documentation (<| (text.prefix ) + (cond (text\= expected_module module) + short + + (text\= .prelude_module module) + (format "." short) + + ... else + (%.name [module short])))] + [(revised@ #.column (n.+ (text.size documentation)) new_location) + (format (padding reference_column old_location new_location) + documentation)])]) + ([#.Identifier ""] + [#.Tag syntax.sigil]) (^template [ ] [[new_location ( value)] @@ -121,8 +125,7 @@ [#.Int [%.int]] [#.Rev [%.rev]] [#.Frac [%.frac]] - [#.Text [%.text]] - [#.Tag [%.name (text.prefix syntax.sigil)]]) + [#.Text [%.text]]) (^template [|<| |>| ] [[group_location ( members)] @@ -492,7 +495,8 @@ [[name parameters] ..declaration]) (do meta.monad [.let [g!module (code.text (product.left name))] - [[_ def_type def_annotations def_value]] (meta.export name)] + [[_ def_type def_annotations def_value]] (meta.export name) + tags (meta.tags_of name)] (with_expansions [<\n> (~! text.\n)] (macro.with_identifiers [g!type] (in (list (` ($_ ((~! md.then)) @@ -517,7 +521,9 @@ ((~! ..type_definition) (~ g!module) [(~ (code.text (product.right name))) (list (~+ (list\each code.text parameters)))] - (list)) + (.list (~+ (|> tags + (maybe.else (list)) + (list\each (|>> product.right code.text)))))) ((~! %.format) ((~! ..single_line_comment) ((~! ..type) (~ g!module) (~ g!type))) <\n>))) diff --git a/stdlib/source/library/lux/meta.lux b/stdlib/source/library/lux/meta.lux index f19bc2964..3cc8deedf 100644 --- a/stdlib/source/library/lux/meta.lux +++ b/stdlib/source/library/lux/meta.lux @@ -505,9 +505,12 @@ [.let [[module_name name] type_name] module (..module module_name)] (case (plist.value name (value@ #.definitions module)) - (#.Some (#.Type [exported? type (#.Right slots)])) - (in (#.Some (list\each (|>> [module_name]) - (#.Item slots)))) + (#.Some (#.Type [exported? type labels])) + (case labels + (^or (#.Left labels) + (#.Right labels)) + (in (#.Some (list\each (|>> [module_name]) + (#.Item labels))))) _ (in #.None)))) diff --git a/stdlib/source/library/lux/tool/compiler/language/lux/syntax.lux b/stdlib/source/library/lux/tool/compiler/language/lux/syntax.lux index 3105f2ad8..734f38260 100644 --- a/stdlib/source/library/lux/tool/compiler/language/lux/syntax.lux +++ b/stdlib/source/library/lux/tool/compiler/language/lux/syntax.lux @@ -435,7 +435,7 @@ (template: (!half_name_parser @offset @char @module) [(!if_name_char?|head @char - (!letE [source' name] (..name_part_parser @offset where (!++ @offset) source_code) + (!letE [source' name] (..name_part_parser @offset (!forward 1 where) (!++ @offset) source_code) (#.Right [source' [@module name]])) (!failure ..!half_name_parser where @offset source_code))]) -- cgit v1.2.3