Stabel

Check-in [1a0f42978d]
Login
Overview
Comment:Module definitions can now contain documentation strings.
Timelines: family | ancestors | descendants | both | strings
Files: files | file ages | folders
SHA3-256: 1a0f42978de4f3ee68bc1544d8836b43b5aa7a99e5ffd15d65414c315a4230d0
User & Date: robin.hansen on 2021-09-05 19:59:26
Other Links: branch diff | manifest | tags
Context
2021-09-06
19:36
Possible finished implementation of strings, need to verify with wasm test. check-in: a046fe223a user: robin.hansen tags: strings
2021-09-05
19:59
Module definitions can now contain documentation strings. check-in: 1a0f42978d user: robin.hansen tags: strings
16:10
Most definitions can now have documentation strings attached. Missing for module definitions. check-in: 882b9bc963 user: robin.hansen tags: strings
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Modified src/Stabel/Parser.elm from [a9412e3bb3] to [acca630c3a].

628
629
630
631
632
633
634





635
636
637
638
639
640
641
        , Parser.inContext ExposingKeyword
            (Parser.succeed (\exposings -> Parser.Loop { def | exposes = exposings })
                |. Parser.keyword (Token "exposing:" UnknownError)
                |. noiseParser
                |= (Parser.loop [] symbolImplListParser |> Parser.map Set.fromList)
                |. noiseParser
            )





        , Parser.succeed UnknownMetadata
            |= metadataParser
            |> Parser.andThen Parser.problem
        , Parser.succeed (Parser.Done def)
            |. Parser.keyword (Token ":" UnknownError)
            |. noiseParser
        ]







>
>
>
>
>







628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
        , Parser.inContext ExposingKeyword
            (Parser.succeed (\exposings -> Parser.Loop { def | exposes = exposings })
                |. Parser.keyword (Token "exposing:" UnknownError)
                |. noiseParser
                |= (Parser.loop [] symbolImplListParser |> Parser.map Set.fromList)
                |. noiseParser
            )
        , Parser.succeed (\str -> Parser.Loop { def | documentation = str })
            |. Parser.keyword (Token "doc:" UnknownError)
            |. noiseParser
            |= stringParser
            |. noiseParser
        , Parser.succeed UnknownMetadata
            |= metadataParser
            |> Parser.andThen Parser.problem
        , Parser.succeed (Parser.Done def)
            |. Parser.keyword (Token ":" UnknownError)
            |. noiseParser
        ]

Modified tests/Test/Parser/ModuleDefinition.elm from [54148a9242] to [74c103f02d].

1
2
3
4
5
6
7
8
..
85
86
87
88
89
90
91















































92
93
94
95
96
97
98
module Test.Parser.ModuleDefinition exposing (..)

import Dict
import Dict.Extra as Dict
import Set
import Stabel.Parser as AST exposing (..)
import Stabel.Parser.AssociatedFunctionSignature as AssociatedFunctionSignature
import Stabel.Parser.ModuleDefinition as ModuleDefinition
................................................................................
                                            [ AST.Integer emptyRange 1
                                            , AST.Function emptyRange "+"
                                            ]
                                  }
                                ]
                        }
                            |> addFunctionsForStructs















































                in
                expectAst source expectedAst
        , test "Functions can have its own aliases and imports" <|
            \_ ->
                let
                    source =
                        """
|







 







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







1
2
3
4
5
6
7
8
..
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
module Test.Parser.ModuleDefinition exposing (suite)

import Dict
import Dict.Extra as Dict
import Set
import Stabel.Parser as AST exposing (..)
import Stabel.Parser.AssociatedFunctionSignature as AssociatedFunctionSignature
import Stabel.Parser.ModuleDefinition as ModuleDefinition
................................................................................
                                            [ AST.Integer emptyRange 1
                                            , AST.Function emptyRange "+"
                                            ]
                                  }
                                ]
                        }
                            |> addFunctionsForStructs
                in
                expectAst source expectedAst
        , test "Documentation string" <|
            \_ ->
                let
                    source =
                        """
                        defmodule:
                        doc: \"\"\"
                        A module for dealing with numbers
                        \"\"\"
                        exposing: inc
                        :

                        def: inc
                        : 1 +
                        """

                    expectedAst =
                        { sourceReference = ""
                        , moduleDefinition =
                            ModuleDefinition.Defined
                                { aliases =
                                    Dict.fromList []
                                , imports =
                                    Dict.fromList
                                        []
                                , exposes = Set.fromList [ "inc" ]
                                , documentation = "A module for dealing with numbers"
                                }
                        , types = Dict.empty
                        , functions =
                            Dict.fromListBy .name
                                [ { name = "inc"
                                  , typeSignature = AssociatedFunctionSignature.NotProvided
                                  , sourceLocationRange = Nothing
                                  , documentation = ""
                                  , aliases = Dict.empty
                                  , imports = Dict.empty
                                  , implementation =
                                        SoloImpl
                                            [ AST.Integer emptyRange 1
                                            , AST.Function emptyRange "+"
                                            ]
                                  }
                                ]
                        }
                in
                expectAst source expectedAst
        , test "Functions can have its own aliases and imports" <|
            \_ ->
                let
                    source =
                        """