@@ -42,32 +42,35 @@ spaces =
43noSpace :: A.Position -> SPos -> Parser ()
43noSpace :: A.Position -> SPos -> Parser ()
44noSpace pos (SPos spos) =
44noSpace pos (SPos spos) =
45+ P.Parser $ \state@(P.State _ _ _ r c context) _ eok _ eerr ->
45− if pos == spos
46+ if pos == spos
46− then return ()
47+ then eok () state
47− else error "TODO what is this again? can it be written better?"
48+ else eerr r c context (E.TODO "noSpace")
50checkSpace :: SPos -> Parser ()
51checkSpace :: SPos -> Parser ()
51checkSpace (SPos (A.Position _ col)) =
52checkSpace (SPos (A.Position _ col)) =
52− do indent <- P.getIndent
53+ P.Parser $ \state@(P.State _ _ indent r c context) _ eok _ eerr ->
53− if col > indent && col > 1
54+ if col > indent && col > 1
54− then return ()
55+ then eok () state
55− else error "TODO what is this again? can it be written better?"
56+ else eerr r c context (E.TODO "checkSpace")
58checkAligned :: SPos -> Parser ()
59checkAligned :: SPos -> Parser ()
59checkAligned (SPos (A.Position _ col)) =
60checkAligned (SPos (A.Position _ col)) =
60− do indent <- P.getIndent
61+ P.Parser $ \state@(P.State _ _ indent r c context) _ eok _ eerr ->
61− if col == indent
62+ if col == indent
62− then return ()
63+ then eok () state
63− else error "TODO what is this again? can it be written better?"
64+ else eerr r c context (E.TODO "checkAligned")
66checkFreshLine :: SPos -> Parser ()
67checkFreshLine :: SPos -> Parser ()
67checkFreshLine (SPos (A.Position _ col)) =
68checkFreshLine (SPos (A.Position _ col)) =
69+ P.Parser $ \state@(P.State _ _ _ r c context) _ eok _ eerr ->
68− if col == 1
70+ if col == 1
69− then return ()
71+ then eok () state
70− else error "TODO what is this again?"
72+ else eerr r c context (E.TODO "checkFreshLine")
73-- WHITESPACE
76-- WHITESPACE
@@ -94,14 +97,14 @@ whitespace =
95 eerr newRow newCol ctx E.NoTabs
98 eerr newRow newCol ctx E.NoTabs
97− UnendingMultiComment ->
100+ UnendingMultiComment sr sc ->
98− eerr newRow newCol ctx E.MultiCommentEnd
101+ eerr newRow newCol ctx (E.MultiCommentEnd sr sc)
101data Status
104data Status
104− | UnendingMultiComment
107+ | UnendingMultiComment Word16 Word16
@@ -180,7 +183,7 @@ eatMultiComment pos end row col =
180 if yesDash && noBar then
183 if yesDash && noBar then
182 (# status, newPos, newRow, newCol #) =
185 (# status, newPos, newRow, newCol #) =
183− eatMultiCommentHelp pos2 end row (col + 2) 1
186+ eatMultiCommentHelp pos2 end row (col + 2) 1 row col
185 case status of
188 case status of
@@ -189,35 +192,35 @@ eatMultiComment pos end row col =
189 HasTab ->
192 HasTab ->
190 (# status, newPos, newRow, newCol #)
193 (# status, newPos, newRow, newCol #)
192− UnendingMultiComment ->
195+ UnendingMultiComment _ _ ->
193 (# status, newPos, newRow, newCol #)
196 (# status, newPos, newRow, newCol #)
196 (# Good, pos, row, col #)
199 (# Good, pos, row, col #)
199−eatMultiCommentHelp :: Ptr Word8 -> Ptr Word8 -> Word16 -> Word16 -> Int -> (# Status, Ptr Word8, Word16, Word16 #)
202+eatMultiCommentHelp :: Ptr Word8 -> Ptr Word8 -> Word16 -> Word16 -> Int -> Word16 -> Word16 -> (# Status, Ptr Word8, Word16, Word16 #)
200−eatMultiCommentHelp pos end row col openComments =
203+eatMultiCommentHelp pos end row col openComments sr sc =
201 if pos >= end then
204 if pos >= end then
202− (# UnendingMultiComment, pos, row, col #)
205+ (# UnendingMultiComment sr sc, pos, row, col #)
205 let !word = P.unsafeIndex pos in
208 let !word = P.unsafeIndex pos in
206 if word == 0x0A {- \n -} then
209 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
209 else if word == 0x2D {- - -} && P.isWord (plusPtr pos 1) end 0x7D {- } -} then
212 else if word == 0x2D {- - -} && P.isWord (plusPtr pos 1) end 0x7D {- } -} then
210 if openComments == 1 then
213 if openComments == 1 then
211 (# Good, plusPtr pos 2, row, col + 2 #)
214 (# Good, plusPtr pos 2, row, col + 2 #)
213− eatMultiCommentHelp (plusPtr pos 2) end row (col + 2) (openComments - 1)
216+ eatMultiCommentHelp (plusPtr pos 2) end row (col + 2) (openComments - 1) sr sc
215 else if word == 0x7B {- { -} && P.isWord (plusPtr pos 1) end 0x2D {- - -} then
218 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
219 let !newPos = plusPtr pos (P.getCharWidth pos end word) in
222 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
@@ -237,7 +240,7 @@ docComment =
239 (# status, newPos, newRow, newCol #) =
242 (# status, newPos, newRow, newCol #) =
240− eatMultiCommentHelp pos3 end row col 1
243+ eatMultiCommentHelp pos3 end row (col + 3) 1 row col
242 case status of
245 case status of
@@ -249,8 +252,8 @@ docComment =
249 HasTab ->
252 HasTab ->
250 eerr newRow newCol ctx E.NoTabs
253 eerr newRow newCol ctx E.NoTabs
252− UnendingMultiComment ->
255+ UnendingMultiComment sr sc ->
253− eerr newRow newCol ctx E.MultiCommentEnd
256+ eerr newRow newCol ctx (E.MultiCommentEnd sr sc)
256 eerr row col ctx E.DocComment
259 eerr row col ctx E.DocComment