@@ -1226,24 +1226,27 @@ adaptCWith pstep initial extract cont !offset0 !usedCount !input = do
12261226 -- The "n" here is stream position index wrt the array start, and
12271227 -- not the backtrack count as returned by byte stream parsers.
12281228 case pRes of
1229- ParserD. Done 0 b ->
1229+ ParserD. SDone 1 b ->
12301230 onDone nextOff b
1231- ParserD. Done 1 b ->
1231+ ParserD. SDone 0 b ->
12321232 onDone curOff b
1233- ParserD. Done n b ->
1234- onDone ((back n - start) `div` elemSize) b
1235- ParserD. Partial 0 pst1 ->
1233+ ParserD. SDone m b ->
1234+ let n = 1 - m
1235+ in onDone ((back n - start) `div` elemSize) b
1236+ ParserD. SPartial 1 pst1 ->
12361237 go SPEC next pst1
1237- ParserD. Partial 1 pst1 ->
1238+ ParserD. SPartial 0 pst1 ->
12381239 go SPEC cur pst1
1239- ParserD. Partial n pst1 ->
1240- onBack (back n) elemSize onPartial pst1
1241- ParserD. Continue 0 pst1 ->
1240+ ParserD. SPartial m pst1 ->
1241+ let n = 1 - m
1242+ in onBack (back n) elemSize onPartial pst1
1243+ ParserD. SContinue 1 pst1 ->
12421244 go SPEC next pst1
1243- ParserD. Continue 1 pst1 ->
1245+ ParserD. SContinue 0 pst1 ->
12441246 go SPEC cur pst1
1245- ParserD. Continue n pst1 ->
1246- onBack (back n) elemSize onContinue pst1
1247+ ParserD. SContinue m pst1 ->
1248+ let n = 1 - m
1249+ in onBack (back n) elemSize onContinue pst1
12471250 ParserD. Error err ->
12481251 onError curOff err
12491252
@@ -1254,17 +1257,19 @@ adaptCWith pstep initial extract cont !offset0 !usedCount !input = do
12541257 -- IMPORTANT: the n here is from the byte stream parser, that means
12551258 -- it is the backtrack element count and not the stream position
12561259 -- index into the current input array.
1257- ParserD. Done n b ->
1258- assert (n >= 0 )
1259- (cont (Success (- n) b) (count - n) None )
1260- ParserD. Continue n pst1 ->
1261- assert (n >= 0 )
1262- (return $ Continue (- n) (parseCont (count - n) pst1))
1260+ ParserD. SDone m b ->
1261+ let n = 1 - m
1262+ in assert (n >= 0 )
1263+ (cont (Success (- n) b) (count - n) None )
1264+ ParserD. SContinue m pst1 ->
1265+ let n = 1 - m
1266+ in assert (n >= 0 )
1267+ (return $ Continue (- n) (parseCont (count - n) pst1))
12631268 ParserD. Error err ->
12641269 -- XXX It is called only when there is no input arr. So using 0
12651270 -- as the position is correct?
12661271 cont (Failure 0 err) count None
1267- ParserD. Partial _ _ -> error " Bug: adaptCWith Partial unreachable"
1272+ ParserD. SPartial _ _ -> error " Bug: adaptCWith Partial unreachable"
12681273
12691274 -- XXX Maybe we can use two separate continuations instead of using
12701275 -- Just/Nothing cases here. That may help in avoiding the parseContJust
0 commit comments