@@ -42,32 +42,35 @@ spaces =
4242
4343noSpace :: A.Position -> SPos -> Parser ()
4444noSpace pos (SPos spos) =
45− if pos == spos
46− then return ()
47− else error "TODO what is this again? can it be written better?"
45+ P.Parser $ \state@(P.State _ _ _ r c context) _ eok _ eerr ->
46+ if pos == spos
47+ then eok () state
48+ else eerr r c context (E.TODO "noSpace")
4849
4950
5051checkSpace :: SPos -> Parser ()
5152checkSpace (SPos (A.Position _ col)) =
52− do indent <- P.getIndent
53− if col > indent && col > 1
54− then return ()
55− else error "TODO what is this again? can it be written better?"
53+ P.Parser $ \state@(P.State _ _ indent r c context) _ eok _ eerr ->
54+ if col > indent && col > 1
55+ then eok () state
56+ else eerr r c context (E.TODO "checkSpace")
5657
5758
5859checkAligned :: SPos -> Parser ()
5960checkAligned (SPos (A.Position _ col)) =
60− do indent <- P.getIndent
61− if col == indent
62− then return ()
63− else error "TODO what is this again? can it be written better?"
61+ P.Parser $ \state@(P.State _ _ indent r c context) _ eok _ eerr ->
62+ if col == indent
63+ then eok () state
64+ else eerr r c context (E.TODO "checkAligned")
6465
6566
6667checkFreshLine :: SPos -> Parser ()
6768checkFreshLine (SPos (A.Position _ col)) =
68− if col == 1
69− then return ()
70− else error "TODO what is this again?"
69+ P.Parser $ \state@(P.State _ _ _ r c context) _ eok _ eerr ->
70+ if col == 1
71+ then eok () state
72+ else eerr r c context (E.TODO "checkFreshLine")
73+
7174
7275
7376-- WHITESPACE
@@ -94,14 +97,14 @@ whitespace =
9497 HasTab ->
9598 eerr newRow newCol ctx E.NoTabs
9699
97− UnendingMultiComment ->
98− eerr newRow newCol ctx E.MultiCommentEnd
100+ UnendingMultiComment sr sc ->
101+ eerr newRow newCol ctx (E.MultiCommentEnd sr sc)
99102
100103
101104data Status
102105 = Good
103106 | HasTab
104− | UnendingMultiComment
107+ | UnendingMultiComment Word16 Word16
105108
106109
107110
@@ -180,7 +183,7 @@ eatMultiComment pos end row col =
180183 if yesDash && noBar then
181184 let
182185 (# status, newPos, newRow, newCol #) =
183− eatMultiCommentHelp pos2 end row (col + 2) 1
186+ eatMultiCommentHelp pos2 end row (col + 2) 1 row col
184187 in
185188 case status of
186189 Good ->
@@ -189,35 +192,35 @@ eatMultiComment pos end row col =
189192 HasTab ->
190193 (# status, newPos, newRow, newCol #)
191194
192− UnendingMultiComment ->
195+ UnendingMultiComment _ _ ->
193196 (# status, newPos, newRow, newCol #)
194197
195198 else
196199 (# Good, pos, row, col #)
197200
198201
199−eatMultiCommentHelp :: Ptr Word8 -> Ptr Word8 -> Word16 -> Word16 -> Int -> (# Status, Ptr Word8, Word16, Word16 #)
200−eatMultiCommentHelp pos end row col openComments =
202+eatMultiCommentHelp :: Ptr Word8 -> Ptr Word8 -> Word16 -> Word16 -> Int -> Word16 -> Word16 -> (# Status, Ptr Word8, Word16, Word16 #)
203+eatMultiCommentHelp pos end row col openComments sr sc =
201204 if pos >= end then
202− (# UnendingMultiComment, pos, row, col #)
205+ (# UnendingMultiComment sr sc, pos, row, col #)
203206
204207 else
205208 let !word = P.unsafeIndex pos in
206209 if word == 0x0A {- \n -} then
207− eatMultiCommentHelp (plusPtr pos 1) end (row + 1) 1 openComments
210+ eatMultiCommentHelp (plusPtr pos 1) end (row + 1) 1 openComments sr sc
208211
209212 else if word == 0x2D {- - -} && P.isWord (plusPtr pos 1) end 0x7D {- } -} then
210213 if openComments == 1 then
211214 (# Good, plusPtr pos 2, row, col + 2 #)
212215 else
213− eatMultiCommentHelp (plusPtr pos 2) end row (col + 2) (openComments - 1)
216+ eatMultiCommentHelp (plusPtr pos 2) end row (col + 2) (openComments - 1) sr sc
214217
215218 else if word == 0x7B {- { -} && P.isWord (plusPtr pos 1) end 0x2D {- - -} then
216− eatMultiCommentHelp (plusPtr pos 2) end row (col + 2) (openComments + 1)
219+ eatMultiCommentHelp (plusPtr pos 2) end row (col + 2) (openComments + 1) sr sc
217220
218221 else
219222 let !newPos = plusPtr pos (P.getCharWidth pos end word) in
220− eatMultiCommentHelp newPos end row (col + 1) openComments
223+ eatMultiCommentHelp newPos end row (col + 1) openComments sr sc
221224
222225
223226
@@ -237,7 +240,7 @@ docComment =
237240 then
238241 let
239242 (# status, newPos, newRow, newCol #) =
240− eatMultiCommentHelp pos3 end row col 1
243+ eatMultiCommentHelp pos3 end row (col + 3) 1 row col
241244 in
242245 case status of
243246 Good ->
@@ -249,8 +252,8 @@ docComment =
249252 HasTab ->
250253 eerr newRow newCol ctx E.NoTabs
251254
252− UnendingMultiComment ->
253− eerr newRow newCol ctx E.MultiCommentEnd
255+ UnendingMultiComment sr sc ->
256+ eerr newRow newCol ctx (E.MultiCommentEnd sr sc)
254257
255258 else
256259 eerr row col ctx E.DocComment