Play

Check-in [4ed17683cd]
Login
Overview
Comment:Can now resolve external word references.
Timelines: family | ancestors | descendants | both | modules
Files: files | file ages | folders
SHA3-256: 4ed17683cd3e8237125f383a7e7f2177b0e244ceb39d004867c59c5bc4c385b4
User & Date: robin.hansen on 2021-02-11 12:56:24
Other Links: branch diff | manifest | tags
Context
2021-02-12
08:40
Add stubbed modules for upcomming PackageLoader feature which loads, parses and qualifies an entire ... check-in: 4ebb2687f0 user: robin.hansen tags: modules
2021-02-11
12:56
Can now resolve external word references. check-in: 4ed17683cd user: robin.hansen tags: modules
11:50
On second thought, externalModules should be a module => package dict. check-in: 9a52bbbd5e user: robin.hansen tags: modules
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Modified src/Play/Qualifier.elm from [6228d648c3] to [7bf41a8a0b].

569
570
571
572
573
574
575
576



















577
578
579
580
581
582
583
            in
            { acc
                | qualifiedNodes = Ok (Word loc qualifiedName) :: acc.qualifiedNodes
                , externalWords = Set.insert ( qualifiedPath, value ) acc.externalWords
            }

        Parser.ExternalWord loc path value ->
            qualifyNode config currentDefName (Parser.Word loc value) acc




















        Parser.ConstructType typeName ->
            { acc | qualifiedNodes = Ok (ConstructType (qualifyName config typeName)) :: acc.qualifiedNodes }

        Parser.SetMember typeName memberName ->
            { acc | qualifiedNodes = Ok (SetMember (qualifyName config typeName) memberName) :: acc.qualifiedNodes }








|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
            in
            { acc
                | qualifiedNodes = Ok (Word loc qualifiedName) :: acc.qualifiedNodes
                , externalWords = Set.insert ( qualifiedPath, value ) acc.externalWords
            }

        Parser.ExternalWord loc path value ->
            let
                normalizedPath =
                    "/" ++ String.join "/" path
            in
            case Dict.get normalizedPath config.externalModules of
                Nothing ->
                    { acc | qualifiedNodes = Err (UnknownWordRef loc (normalizedPath ++ "/" ++ value)) :: acc.qualifiedNodes }

                Just package ->
                    let
                        qualifiedPath =
                            "/" ++ package ++ normalizedPath

                        fullReference =
                            qualifiedPath ++ "/" ++ value
                    in
                    { acc
                        | qualifiedNodes = Ok (Word loc fullReference) :: acc.qualifiedNodes
                        , externalWords = Set.insert ( qualifiedPath, value ) acc.externalWords
                    }

        Parser.ConstructType typeName ->
            { acc | qualifiedNodes = Ok (ConstructType (qualifyName config typeName)) :: acc.qualifiedNodes }

        Parser.SetMember typeName memberName ->
            { acc | qualifiedNodes = Ok (SetMember (qualifyName config typeName) memberName) :: acc.qualifiedNodes }

Modified tests/Test/Qualifier/Error.elm from [83e86d1bc6] to [42c36a26bb].

45
46
47
48
49
50
51





















52
53
54
55
56
57
58
                                                , AST.Word emptyRange "="
                                                ]
                                      }
                                    ]
                            }
                    in
                    checkForError (noSuchWordReferenceError "dec") ast





















            , test "Type" <|
                \_ ->
                    let
                        ast =
                            { types = Dict.empty
                            , words =
                                Dict.fromListBy .name







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
                                                , AST.Word emptyRange "="
                                                ]
                                      }
                                    ]
                            }
                    in
                    checkForError (noSuchWordReferenceError "dec") ast
            , test "External" <|
                \_ ->
                    let
                        ast =
                            { types = Dict.empty
                            , words =
                                Dict.fromListBy .name
                                    [ { name = "main"
                                      , metadata =
                                            Metadata.default
                                                |> Metadata.asEntryPoint
                                      , implementation =
                                            AST.SoloImpl
                                                [ AST.Integer emptyRange 1
                                                , AST.Word emptyRange "/external/module/inc"
                                                ]
                                      }
                                    ]
                            }
                    in
                    checkForError (noSuchWordReferenceError "/external/module/inc") ast
            , test "Type" <|
                \_ ->
                    let
                        ast =
                            { types = Dict.empty
                            , words =
                                Dict.fromListBy .name