@@ -43,6 +43,9 @@ import qualified Parse.Expression as PE
43import qualified Parse.Declaration as PD
43import qualified Parse.Declaration as PD
44import qualified Parse.Module as PM
44import qualified Parse.Module as PM
45import qualified Parse.Primitives as P
45import qualified Parse.Primitives as P
46+import qualified Parse.Space as PS
47+import qualified Parse.Type as PT
48+import qualified Parse.Variable as PV
46import Parse.Primitives (Row, Col)
49import Parse.Primitives (Row, Col)
47import qualified Reporting
50import qualified Reporting
48import qualified Reporting.Annotation as A
51import qualified Reporting.Annotation as A
@@ -172,12 +175,12 @@ read =
173 case categorize lines of
176 case categorize lines of
174 Done input -> return input
177 Done input -> return input
175− Continue -> readMore lines
178+ Continue p -> readMore lines p
178−readMore :: Lines -> Repl.InputT M Input
181+readMore :: Lines -> Prefill -> Repl.InputT M Input
179−readMore previousLines =
182+readMore previousLines prefill =
180− do input <- Repl.getInputLineWithInitial "| " (" ","")
183+ do input <- Repl.getInputLineWithInitial "| " (renderPrefill prefill, "")
181 case input of
184 case input of
182 Nothing ->
185 Nothing ->
183 return Skip
186 return Skip
@@ -188,7 +191,22 @@ readMore previousLines =
189 case categorize lines of
192 case categorize lines of
190 Done input -> return input
193 Done input -> return input
191− Continue -> readMore lines
194+ Continue p -> readMore lines p
202+renderPrefill :: Prefill -> String
203+renderPrefill lineStart =
209+ N.toChars name ++ " "
@@ -241,7 +259,7 @@ getFirstLine (Lines x xs) =
242data CategorizedInput
260data CategorizedInput
243 = Done Input
261 = Done Input
244− | Continue
262+ | Continue Prefill
247categorize :: Lines -> CategorizedInput
265categorize :: Lines -> CategorizedInput
@@ -270,14 +288,14 @@ ifFail :: Lines -> Input -> CategorizedInput
270ifFail lines input =
288ifFail lines input =
271 if endsWithBlankLine lines
289 if endsWithBlankLine lines
272 then Done input
290 then Done input
273− else Continue
291+ else Continue Indent
276ifDone :: Lines -> Input -> CategorizedInput
294ifDone :: Lines -> Input -> CategorizedInput
277ifDone lines input =
295ifDone lines input =
278 if isSingleLine lines || endsWithBlankLine lines
296 if isSingleLine lines || endsWithBlankLine lines
279 then Done input
297 then Done input
280− else Continue
298+ else Continue Indent
283attemptDeclOrExpr :: Lines -> CategorizedInput
301attemptDeclOrExpr :: Lines -> CategorizedInput
@@ -311,7 +329,9 @@ attemptDeclOrExpr lines =
311 if exprPosition >= declPosition then
329 if exprPosition >= declPosition then
312 ifFail lines (Expr src)
330 ifFail lines (Expr src)
332+ case P.fromByteString annotation (\_ _ -> ()) src of
333+ Right name -> Continue (DefStart name)
314− ifFail lines (Decl "ERR" src)
334+ Left () -> ifFail lines (Decl "ERR" src)
317startsWithColon :: Lines -> Bool
337startsWithColon :: Lines -> Bool
@@ -361,6 +381,21 @@ toDeclPosition src decl r c =
361 (row, col)
381 (row, col)
384+annotation :: P.Parser () N.Name
390+ do name <- PV.lower err
391+ PS.chompAndCheckIndent err_ err
392+ P.word1 0x3A {-:-} err
393+ PS.chompAndCheckIndent err_ err
394+ (_, _) <- P.specialize err_ PT.expression
395+ PS.checkFreshLine err