Stabel

Check-in [24cb64e9da]
Login
Overview
Comment:Change order of fields for alias: metadata [c2996a5e70].
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 24cb64e9dae48f68776410d695bd526ee4a73a0b2522303d4250379c0d80bac7
User & Date: robin.hansen on 2021-09-20 16:18:10
Other Links: manifest | tags
Context
2021-09-20
16:33
Aliases can now be implicit [c2996a5e70] check-in: 7c8e530718 user: robin.hansen tags: trunk
16:18
Change order of fields for alias: metadata [c2996a5e70]. check-in: 24cb64e9da user: robin.hansen tags: trunk
2021-09-18
10:28
Change auto-generated ctor name for memberless structs. [c2996a5e70] check-in: 2badc579e3 user: robin.hansen tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Modified src/Stabel/Parser.elm from [c92d858572] to [ae1250b7de].

757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
...
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
....
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102

moduleDefinitionMetaParser :
    ModuleDefinition.Definition
    -> Parser (Parser.Step ModuleDefinition.Definition ModuleDefinition.Definition)
moduleDefinitionMetaParser def =
    Parser.oneOf
        [ Parser.inContext Problem.AliasKeyword
            (Parser.succeed (\alias value -> Parser.Loop { def | aliases = Dict.insert alias value def.aliases })
                |. Parser.keyword (Token "alias:" UnknownError)
                |. noiseParser
                |= symbolParser
                |. noiseParser
                |= modulePathStringParser
                |. noiseParser
            )
        , Parser.inContext Problem.ImportKeyword
            (Parser.succeed (\mod vals -> Parser.Loop { def | imports = Dict.insert mod vals def.imports })
                |. Parser.keyword (Token "import:" UnknownError)
                |. noiseParser
                |= modulePathStringParser
................................................................................
        , Parser.inContext Problem.DocKeyword <|
            Parser.succeed (\str -> Parser.Loop { def | documentation = str })
                |. Parser.keyword (Token "doc:" UnknownError)
                |. noiseParser
                |= stringParser
                |. noiseParser
        , Parser.inContext Problem.AliasKeyword <|
            Parser.succeed (\alias value -> Parser.Loop { def | aliases = Dict.insert alias value def.aliases })
                |. Parser.keyword (Token "alias:" UnknownError)
                |. noiseParser
                |= symbolParser
                |. noiseParser
                |= modulePathStringParser
                |. noiseParser
        , Parser.inContext Problem.ImportKeyword <|
            Parser.succeed (\mod vals -> Parser.Loop { def | imports = Dict.insert mod vals def.imports })
                |. Parser.keyword (Token "import:" UnknownError)
                |. noiseParser
                |= modulePathStringParser
                |. noiseParser
................................................................................
                |. noiseParser
        , Parser.inContext Problem.ElseKeyword <|
            Parser.succeed (\impl -> Parser.Loop { def | implementation = setDefaultImpl impl })
                |. Parser.keyword (Token "else:" UnknownError)
                |. noiseParser
                |= implementationParser
        , Parser.inContext Problem.AliasKeyword <|
            Parser.succeed (\alias value -> Parser.Loop { def | aliases = Dict.insert alias value def.aliases })
                |. Parser.keyword (Token "alias:" UnknownError)
                |. noiseParser
                |= symbolParser
                |. noiseParser
                |= modulePathStringParser
                |. noiseParser
        , Parser.inContext Problem.ImportKeyword <|
            Parser.succeed (\mod vals -> Parser.Loop { def | imports = Dict.insert mod vals def.imports })
                |. Parser.keyword (Token "import:" UnknownError)
                |. noiseParser
                |= modulePathStringParser
                |. noiseParser







|


|

|







 







|


|

|







 







|


|

|







757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
...
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
....
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102

moduleDefinitionMetaParser :
    ModuleDefinition.Definition
    -> Parser (Parser.Step ModuleDefinition.Definition ModuleDefinition.Definition)
moduleDefinitionMetaParser def =
    Parser.oneOf
        [ Parser.inContext Problem.AliasKeyword
            (Parser.succeed (\value alias -> Parser.Loop { def | aliases = Dict.insert alias value def.aliases })
                |. Parser.keyword (Token "alias:" UnknownError)
                |. noiseParser
                |= modulePathStringParser
                |. noiseParser
                |= symbolParser
                |. noiseParser
            )
        , Parser.inContext Problem.ImportKeyword
            (Parser.succeed (\mod vals -> Parser.Loop { def | imports = Dict.insert mod vals def.imports })
                |. Parser.keyword (Token "import:" UnknownError)
                |. noiseParser
                |= modulePathStringParser
................................................................................
        , Parser.inContext Problem.DocKeyword <|
            Parser.succeed (\str -> Parser.Loop { def | documentation = str })
                |. Parser.keyword (Token "doc:" UnknownError)
                |. noiseParser
                |= stringParser
                |. noiseParser
        , Parser.inContext Problem.AliasKeyword <|
            Parser.succeed (\value alias -> Parser.Loop { def | aliases = Dict.insert alias value def.aliases })
                |. Parser.keyword (Token "alias:" UnknownError)
                |. noiseParser
                |= modulePathStringParser
                |. noiseParser
                |= symbolParser
                |. noiseParser
        , Parser.inContext Problem.ImportKeyword <|
            Parser.succeed (\mod vals -> Parser.Loop { def | imports = Dict.insert mod vals def.imports })
                |. Parser.keyword (Token "import:" UnknownError)
                |. noiseParser
                |= modulePathStringParser
                |. noiseParser
................................................................................
                |. noiseParser
        , Parser.inContext Problem.ElseKeyword <|
            Parser.succeed (\impl -> Parser.Loop { def | implementation = setDefaultImpl impl })
                |. Parser.keyword (Token "else:" UnknownError)
                |. noiseParser
                |= implementationParser
        , Parser.inContext Problem.AliasKeyword <|
            Parser.succeed (\value alias -> Parser.Loop { def | aliases = Dict.insert alias value def.aliases })
                |. Parser.keyword (Token "alias:" UnknownError)
                |. noiseParser
                |= modulePathStringParser
                |. noiseParser
                |= symbolParser
                |. noiseParser
        , Parser.inContext Problem.ImportKeyword <|
            Parser.succeed (\mod vals -> Parser.Loop { def | imports = Dict.insert mod vals def.imports })
                |. Parser.keyword (Token "import:" UnknownError)
                |. noiseParser
                |= modulePathStringParser
                |. noiseParser

Modified tests/Test/Parser/ModuleDefinition.elm from [bfe56510f7] to [0789548606].

21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
...
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
...
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
    describe "Parser -- ModuleDefinition"
        [ test "Imports and aliases" <|
            \_ ->
                let
                    source =
                        """
                        defmodule:
                        alias: other /some/mod
                        alias: moar local/mod
                        import: /some/other/mod test1 word2
                        import: internals foo
                        import: internal/mod
                        exposing: inc
                        :

                        defstruct: Pair a b
................................................................................
                expectAst source expectedAst
        , test "Functions can have its own aliases and imports" <|
            \_ ->
                let
                    source =
                        """
                        def: inc
                        alias: other /some/mod
                        alias: moar local/mod
                        import: /some/other/mod test1 word2
                        import: internals foo
                        import: internal/mod
                        : 1 +
                        """

                    expectedAst =
................................................................................
                expectAst source expectedAst
        , test "Multifunctions can have its own aliases and imports" <|
            \_ ->
                let
                    source =
                        """
                        defmulti: with-default
                        alias: other /some/mod
                        alias: moar local/mod
                        import: /some/other/mod test1 word2
                        import: internals foo
                        import: internal/mod
                        : a
                          drop
                        else:
                          swap drop







|
|







 







|
|







 







|
|







21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
...
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
...
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
    describe "Parser -- ModuleDefinition"
        [ test "Imports and aliases" <|
            \_ ->
                let
                    source =
                        """
                        defmodule:
                        alias: /some/mod other
                        alias: local/mod moar
                        import: /some/other/mod test1 word2
                        import: internals foo
                        import: internal/mod
                        exposing: inc
                        :

                        defstruct: Pair a b
................................................................................
                expectAst source expectedAst
        , test "Functions can have its own aliases and imports" <|
            \_ ->
                let
                    source =
                        """
                        def: inc
                        alias: /some/mod other 
                        alias: local/mod moar 
                        import: /some/other/mod test1 word2
                        import: internals foo
                        import: internal/mod
                        : 1 +
                        """

                    expectedAst =
................................................................................
                expectAst source expectedAst
        , test "Multifunctions can have its own aliases and imports" <|
            \_ ->
                let
                    source =
                        """
                        defmulti: with-default
                        alias: /some/mod other 
                        alias: local/mod moar 
                        import: /some/other/mod test1 word2
                        import: internals foo
                        import: internal/mod
                        : a
                          drop
                        else:
                          swap drop

Modified tests/Test/Qualifier.elm from [9aef3f3120] to [5a6565cefb].

424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
...
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
...
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
                QualifierUtil.expectModuleOutput source expectedAst
        , test "Retrieve dependant modules" <|
            \_ ->
                let
                    source =
                        """
                        defmodule:
                        alias: html /external/html
                        import: /external/module
                        :

                        defstruct: Tipe
                        : value /external/double/Tipe

                        defmulti: call-external
................................................................................
                        : Int( value 1 )
                          package/module/when-one
                        : internal/match/Some
                          drop
                        else: package/module/when-other-one

                        def: main
                        alias: ali internal/alias
                        import: /list/of/names one
                        : html/div
                          call-external
                          /some/ext/word
                          ali/word1

                        def: string-hello
................................................................................
                        Expect.equal expectedRequiredModules actualRequiredModules
        , test "Reliance on standard_library/core only when standard_library is specified as externalModule" <|
            \_ ->
                let
                    source =
                        """
                        def: main
                        alias: ali internal/alias
                        : ali/word1
                        """

                    expectedRequiredModules =
                        Set.fromList
                            [ "/package/test/internal/alias"
                            ]







|







 







|







 







|







424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
...
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
...
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
                QualifierUtil.expectModuleOutput source expectedAst
        , test "Retrieve dependant modules" <|
            \_ ->
                let
                    source =
                        """
                        defmodule:
                        alias: /external/html html 
                        import: /external/module
                        :

                        defstruct: Tipe
                        : value /external/double/Tipe

                        defmulti: call-external
................................................................................
                        : Int( value 1 )
                          package/module/when-one
                        : internal/match/Some
                          drop
                        else: package/module/when-other-one

                        def: main
                        alias: internal/alias ali 
                        import: /list/of/names one
                        : html/div
                          call-external
                          /some/ext/word
                          ali/word1

                        def: string-hello
................................................................................
                        Expect.equal expectedRequiredModules actualRequiredModules
        , test "Reliance on standard_library/core only when standard_library is specified as externalModule" <|
            \_ ->
                let
                    source =
                        """
                        def: main
                        alias: internal/alias ali 
                        : ali/word1
                        """

                    expectedRequiredModules =
                        Set.fromList
                            [ "/package/test/internal/alias"
                            ]

Modified wasm_tests/module_resolution.test.js from [979dc2e0f5] to [a03584297b].

218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
                `
            },
            {
                package: 'author/sample',
                module: 'core',
                source: `
                    defmodule:
                    alias: ext /mod
                    alias: tope internal/tope
                    :

                    defstruct: TipeTope
                    : first tope/Tope

                    def: main
                    alias: internal internal/mod
                    : 6 
                      internal/value
                      ext/add

                    def: noop
                    alias: tipe /tipe
                    type: tipe/Tipe tope/Tope --
                    : drop drop

                    defmulti: as-int
                    alias: tipe /tipe
                    : tipe/Tipe
                      drop 1
                    : tope/Tope
                      drop 2
                `
            },
        ]







|
|






|





|




|







218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
                `
            },
            {
                package: 'author/sample',
                module: 'core',
                source: `
                    defmodule:
                    alias: /mod ext 
                    alias: internal/tope tope 
                    :

                    defstruct: TipeTope
                    : first tope/Tope

                    def: main
                    alias: internal/mod internal 
                    : 6 
                      internal/value
                      ext/add

                    def: noop
                    alias: /tipe tipe 
                    type: tipe/Tipe tope/Tope --
                    : drop drop

                    defmulti: as-int
                    alias: /tipe tipe 
                    : tipe/Tipe
                      drop 1
                    : tope/Tope
                      drop 2
                `
            },
        ]