Play

Check-in [ec17f65074]
Login
Overview
Comment:Fixed bug when parsing words which could result in two words being interpreted as one.
Timelines: family | ancestors | descendants | both | cli
Files: files | file ages | folders
SHA3-256: ec17f65074216406e4868a92f3bfa0a71cae47e93bbd52d38cde6efb2b7fc12b
User & Date: robin.hansen on 2021-04-03 07:29:00
Other Links: branch diff | manifest | tags
Context
2021-04-03
07:56
Remove debug statement. check-in: 874da70254 user: robin.hansen tags: cli
07:29
Fixed bug when parsing words which could result in two words being interpreted as one. check-in: ec17f65074 user: robin.hansen tags: cli
2021-04-02
12:37
cli.js <-> CLI.elm interop completed, but there seems to be a bug in the parser that needs to be fix... check-in: 695ec5f34b user: robin.hansen tags: cli
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Modified src/Play/Parser.elm from [8b0faf8562] to [f9f02c0303].

175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
...
230
231
232
233
234
235
236

237
238
239
240
241
242
243
        }
        |. Parser.oneOf
            [ Parser.succeed identity
                |. Parser.symbol (Token ":" NotMetadata)
                |> Parser.andThen (\_ -> Parser.problem FoundMetadata)
            , Parser.succeed identity
            ]
        |. noiseParser
        |> Parser.backtrackable


symbolImplParser2 : Parser (SourceLocationRange -> AstNode)
symbolImplParser2 =
    let
        externalBuilder firstSymbol (( partialPath, reference ) as modulePathResult) =
................................................................................
        , Parser.succeed internalBuilder
            |= symbolImplParser
            |= Parser.oneOf
                [ Parser.loop [] modulePathParser
                , Parser.succeed ( [], "" )
                ]
        ]

        |> Parser.andThen identity


modulePathParser : List String -> Parser (Parser.Step (List String) ( List String, String ))
modulePathParser symbols =
    Parser.oneOf
        [ Parser.succeed (\name -> Parser.Loop (name :: symbols))







<







 







>







175
176
177
178
179
180
181

182
183
184
185
186
187
188
...
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
        }
        |. Parser.oneOf
            [ Parser.succeed identity
                |. Parser.symbol (Token ":" NotMetadata)
                |> Parser.andThen (\_ -> Parser.problem FoundMetadata)
            , Parser.succeed identity
            ]

        |> Parser.backtrackable


symbolImplParser2 : Parser (SourceLocationRange -> AstNode)
symbolImplParser2 =
    let
        externalBuilder firstSymbol (( partialPath, reference ) as modulePathResult) =
................................................................................
        , Parser.succeed internalBuilder
            |= symbolImplParser
            |= Parser.oneOf
                [ Parser.loop [] modulePathParser
                , Parser.succeed ( [], "" )
                ]
        ]
        |. noiseParser
        |> Parser.andThen identity


modulePathParser : List String -> Parser (Parser.Step (List String) ( List String, String ))
modulePathParser symbols =
    Parser.oneOf
        [ Parser.succeed (\name -> Parser.Loop (name :: symbols))

Modified tests/Test/Parser.elm from [183827d1df] to [a9f19ae62c].

764
765
766
767
768
769
770






























771
772
773
774
775
776
777
                                      , metadata = Metadata.default
                                      , implementation =
                                            SoloImpl
                                                [ AST.ExternalWord emptyRange [ "some", "module" ] "sample" ]
                                      }
                                    ]
                            }






























                    in
                    case compile source of
                        Err _ ->
                            Expect.fail "Did not expect parsing to fail"

                        Ok ast ->
                            Expect.equal expectedAst ast







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







764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
                                      , metadata = Metadata.default
                                      , implementation =
                                            SoloImpl
                                                [ AST.ExternalWord emptyRange [ "some", "module" ] "sample" ]
                                      }
                                    ]
                            }
                    in
                    case compile source of
                        Err _ ->
                            Expect.fail "Did not expect parsing to fail"

                        Ok ast ->
                            Expect.equal expectedAst ast
            , test "internal _and_ external reference" <|
                \_ ->
                    let
                        source =
                            """
                            def: test
                            : internal/sample /some/module/sample
                            """

                        expectedAst =
                            { types = Dict.empty
                            , words =
                                Dict.fromListBy .name
                                    [ { name = "test"
                                      , metadata = Metadata.default
                                      , implementation =
                                            SoloImpl
                                                [ AST.PackageWord emptyRange [ "internal" ] "sample"
                                                , AST.ExternalWord emptyRange [ "some", "module" ] "sample"
                                                ]
                                      }
                                    ]
                            }
                    in
                    case compile source of
                        Err _ ->
                            Expect.fail "Did not expect parsing to fail"

                        Ok ast ->
                            Expect.equal expectedAst ast