@@ -114,7 +114,7 @@ stackSafeLoopsTest = do
114
114
parseErrorTestPosition
115
115
(many1TillRec (string " a" ) (string " b" ))
116
116
" baa"
117
- (Position { line: 1 , column: 1 })
117
+ (Position { index: 0 , line: 1 , column: 1 })
118
118
119
119
parseTest " a,a,a,b,a,a" (toUnfoldable [ " a" , " a" , " a" ]) $
120
120
sepEndByRec (string " a" ) (string " ," )
@@ -130,7 +130,7 @@ stackSafeLoopsTest = do
130
130
parseErrorTestPosition
131
131
(sepEndBy1Rec (string " a" ) (string " ," ))
132
132
" b,a,a"
133
- (Position { line: 1 , column: 1 })
133
+ (Position { index: 0 , line: 1 , column: 1 })
134
134
135
135
-- 8 `div` (8 `div` 2) == 2
136
136
parseTest " 8x8x2" 2 $
@@ -142,7 +142,7 @@ stackSafeLoopsTest = do
142
142
parseErrorTestPosition
143
143
(chainr1Rec digit (string " x" $> div))
144
144
" "
145
- (Position { line: 1 , column: 1 })
145
+ (Position { index: 0 , line: 1 , column: 1 })
146
146
147
147
-- (8 `div` 2) `div` 2 == 2
148
148
parseTest " 8x2x2" 2 $
@@ -154,15 +154,15 @@ stackSafeLoopsTest = do
154
154
parseErrorTestPosition
155
155
(chainl1Rec digit (string " x" $> div))
156
156
" "
157
- (Position { line: 1 , column: 1 })
157
+ (Position { index: 0 , line: 1 , column: 1 })
158
158
159
159
parseTest " aaaabcd" " b"
160
160
$ skipMany1Rec (string " a" )
161
161
*> string " b"
162
162
parseErrorTestPosition
163
163
(skipMany1Rec (string " a" ))
164
164
" bcd"
165
- (Position { line: 1 , column: 1 })
165
+ (Position { index: 0 , line: 1 , column: 1 })
166
166
167
167
parseTest " aaaabcd" " b"
168
168
$ skipManyRec (string " a" )
@@ -176,7 +176,7 @@ stackSafeLoopsTest = do
176
176
parseErrorTestPosition
177
177
(many1Rec (string " a" ))
178
178
" "
179
- (Position { line: 1 , column: 1 })
179
+ (Position { index: 0 , line: 1 , column: 1 })
180
180
181
181
parseTest " a,a,ab" (toUnfoldable [ " a" , " a" , " a" ])
182
182
$ sepByRec (string " a" ) (string " ," )
@@ -190,11 +190,11 @@ stackSafeLoopsTest = do
190
190
parseErrorTestPosition
191
191
(sepBy1Rec (string " a" ) (string " ," ))
192
192
" "
193
- (Position { line: 1 , column: 1 })
193
+ (Position { index: 0 , line: 1 , column: 1 })
194
194
parseErrorTestPosition
195
195
(sepBy1Rec (string " a" ) (string " ," ))
196
196
" a,"
197
- (Position { line: 1 , column: 3 })
197
+ (Position { index: 2 , line: 1 , column: 3 })
198
198
199
199
parseTest " a,a,a,b" (toUnfoldable [ " a" , " a" , " a" ])
200
200
$ endByRec (string " a" ) (string " ," )
@@ -208,11 +208,11 @@ stackSafeLoopsTest = do
208
208
parseErrorTestPosition
209
209
(endBy1Rec (string " a" ) (string " ," ))
210
210
" "
211
- (Position { line: 1 , column: 1 })
211
+ (Position { index: 0 , line: 1 , column: 1 })
212
212
parseErrorTestPosition
213
213
(endBy1Rec (string " a" ) (string " ," ))
214
214
" a,a"
215
- (Position { line: 1 , column: 4 })
215
+ (Position { index: 3 , line: 1 , column: 4 })
216
216
217
217
data TestToken = A | B
218
218
@@ -233,10 +233,7 @@ testTokenParser :: TokenParser
233
233
testTokenParser = makeTokenParser haskellDef
234
234
235
235
mkPos :: Int -> Position
236
- mkPos n = mkPos' n 1
237
-
238
- mkPos' :: Int -> Int -> Position
239
- mkPos' column line = Position { column: column, line: line }
236
+ mkPos n = Position { index: n - 1 , line: 1 , column: n }
240
237
241
238
type TestM = Effect Unit
242
239
@@ -562,12 +559,12 @@ main = do
562
559
parseErrorTestPosition
563
560
(many $ char ' f' *> char ' ?' )
564
561
" foo"
565
- (Position { column: 2 , line: 1 })
562
+ (Position { index: 1 , column: 2 , line: 1 })
566
563
567
564
parseErrorTestPosition
568
565
(satisfy (_ == ' ?' ))
569
566
" foo"
570
- (Position { column: 1 , line: 1 })
567
+ (Position { index: 0 , column: 1 , line: 1 })
571
568
572
569
parseTest
573
570
" foo"
@@ -592,17 +589,17 @@ main = do
592
589
593
590
parseTest " rest" " rest" rest
594
591
parseTest " rest" unit (rest *> eof)
595
- parseTest " rest\n rest" (Position { line: 2 , column: 5 }) (rest *> position)
592
+ parseTest " rest\n rest" (Position { index: 9 , line: 2 , column: 5 }) (rest *> position)
596
593
597
594
parseErrorTestPosition
598
595
(rest *> notFollowedBy eof)
599
596
" aa\n aa"
600
- (Position { column: 3 , line: 2 })
597
+ (Position { index: 5 , column: 3 , line: 2 })
601
598
602
599
parseErrorTestPosition
603
- anyChar
604
- " π
‘"
605
- (Position { column: 1 , line: 1 })
600
+ (string " π
π
" *> string " π
π
" )
601
+ " π
π
x π
‘"
602
+ (Position { index: 2 , column: 3 , line: 1 })
606
603
607
604
parseTest " π
π
xπ
‘" [ " π
" , " π
" , " x" , " π
‘" ] do
608
605
quarter <- anyCodePoint
@@ -618,8 +615,8 @@ main = do
618
615
619
616
parseTest " abcd" " ab" $ takeN 2
620
617
parseTest " abcd" " " $ takeN 0
621
- parseErrorTestPosition (takeN 10 ) " abcd" (Position { column: 1 , line: 1 })
622
- parseErrorTestPosition (takeN (-1 )) " abcd" (Position { column: 1 , line: 1 })
618
+ parseErrorTestPosition (takeN 10 ) " abcd" (Position { index: 0 , column: 1 , line: 1 })
619
+ parseErrorTestPosition (takeN (-1 )) " abcd" (Position { index: 0 , column: 1 , line: 1 })
623
620
624
621
parseErrorTestMessage
625
622
(noneOfCodePoints $ SCP .toCodePointArray " ββ
" )
@@ -662,10 +659,10 @@ main = do
662
659
parseTest " ababab" [ ' b' , ' b' , ' b' ] $ Array .many (char ' a' *> char ' b' )
663
660
parseTest " abaXab" [ ' b' ] $ Array .many (try (char ' a' *> char ' b' ))
664
661
665
- parseErrorTestPosition (string " abc" ) " bcd" (Position { column: 1 , line: 1 })
666
- parseErrorTestPosition (string " abc" *> eof) " abcdefg" (Position { column: 4 , line: 1 })
667
- parseErrorTestPosition (string " a\n b\n c\n " *> eof) " a\n b\n c\n d\n " (Position { column: 1 , line: 4 })
668
- parseErrorTestPosition (string " \t a" *> eof) " \t ab" (Position { column: 10 , line: 1 })
662
+ parseErrorTestPosition (string " abc" ) " bcd" (Position { index: 0 , column: 1 , line: 1 })
663
+ parseErrorTestPosition (string " abc" *> eof) " abcdefg" (Position { index: 3 , column: 4 , line: 1 })
664
+ parseErrorTestPosition (string " a\n b\n c\n " *> eof) " a\n b\n c\n d\n " (Position { index: 6 , column: 1 , line: 4 })
665
+ parseErrorTestPosition (string " \t a" *> eof) " \t ab" (Position { index: 2 , column: 10 , line: 1 })
669
666
670
667
parseTest " Infinity" infinity number
671
668
parseTest " +Infinity" infinity number
0 commit comments