@@ -10,6 +10,7 @@ module Parse.Space
1010 , checkAligned
1111 , checkFreshLine
1212 --
13+ , DocComment(..)
1314 , docComment
1415 )
1516 where
@@ -87,7 +88,7 @@ checkFreshLine toError =
8788
8889
8990chompAndCheckIndent :: (E.Space -> Row -> Col -> x) -> (Row -> Col -> x) -> P.Parser x ()
90−chompAndCheckIndent toWhitespaceError toIndentError =
91+chompAndCheckIndent toSpaceError toIndentError =
9192 P.Parser $ \(P.State pos end indent row col) cok _ cerr _ ->
9293 let
9394 (# status, newPos, newRow, newCol #) = eatSpaces pos end row col
@@ -105,9 +106,9 @@ chompAndCheckIndent toWhitespaceError toIndentError =
105106 else
106107 cerr row col toIndentError
107108
108− HasTab -> cerr newRow newCol (toWhitespaceError E.HasTab)
109− EndlessMultiComment -> cerr newRow newCol (toWhitespaceError E.EndlessMultiComment)
110− UnexpectedDocComment -> cerr newRow newCol (toWhitespaceError E.UnexpectedDocComment)
109+ HasTab -> cerr newRow newCol (toSpaceError E.HasTab)
110+ EndlessMultiComment -> cerr newRow newCol (toSpaceError E.EndlessMultiComment)
111+ UnexpectedDocComment -> cerr newRow newCol (toSpaceError E.UnexpectedDocComment)
111112
112113
113114
@@ -240,8 +241,15 @@ eatMultiCommentHelp pos end row col openComments =
240241-- DOCUMENTATION COMMENT
241242
242243
243−docComment :: (Row -> Col -> x) -> (Row -> Col -> x) -> (Row -> Col -> x) -> P.Parser x ()
244−docComment toExpectation toTabError toEndlessError =
244+data DocComment =
245+ DocComment
246+ { _start :: Ptr Word8
247+ , _end :: Ptr Word8
248+ }
249+
250+
251+docComment :: (Row -> Col -> x) -> (E.Space -> Row -> Col -> x) -> P.Parser x DocComment
252+docComment toExpectation toSpaceError =
245253 P.Parser $ \(P.State pos end indent row col) cok _ cerr eerr ->
246254 let
247255 !pos3 = plusPtr pos 3
@@ -258,11 +266,12 @@ docComment toExpectation toTabError toEndlessError =
258266 case status of
259267 MultiGood ->
260268 let
269+ !comment = DocComment pos3 (plusPtr newPos (-2))
261270 !newState = P.State newPos end indent newRow newCol
262271 in
263− cok () newState
272+ cok comment newState
264273
265− MultiTab -> cerr newRow newCol toTabError
266− MultiEndless -> cerr row col toEndlessError
274+ MultiTab -> cerr newRow newCol (toSpaceError E.HasTab)
275+ MultiEndless -> cerr row col (toSpaceError E.EndlessMultiComment)
267276 else
268277 eerr row col toExpectation