diff options
author | Eduardo Julian | 2021-08-30 04:21:53 -0400 |
---|---|---|
committer | Eduardo Julian | 2021-08-30 04:21:53 -0400 |
commit | 834ed92e323fd274c2da08c82a7d8785663e10be (patch) | |
tree | d7b0f211c50a74f70a1ae01f5311be4e06575f4d /stdlib/source/library | |
parent | ef437d6584d8fd863c0dab276e5a3d4dc094767b (diff) |
Better tagged type documentation + lexer fix.
Diffstat (limited to 'stdlib/source/library')
-rw-r--r-- | stdlib/source/library/lux/documentation.lux | 38 | ||||
-rw-r--r-- | stdlib/source/library/lux/meta.lux | 9 | ||||
-rw-r--r-- | stdlib/source/library/lux/tool/compiler/language/lux/syntax.lux | 2 |
3 files changed, 29 insertions, 20 deletions
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 [<tag> <prefix>] + [[new_location (<tag> [module short])] + (let [documentation (<| (text.prefix <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 [<tag> <format>] [[new_location (<tag> value)] @@ -121,8 +125,7 @@ [#.Int [%.int]] [#.Rev [%.rev]] [#.Frac [%.frac]] - [#.Text [%.text]] - [#.Tag [%.name (text.prefix syntax.sigil)]]) + [#.Text [%.text]]) (^template [|<| |>| <tag> <prep>] [[group_location (<tag> 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))]) |