git.iko.soy/typeable/attoparsec
on master help sign in
Small edits.
commita3f7078d9852b452f33d81de0f8a8b218fb7e71a authorBryan O'Sullivan <bos@serpentine.com> dateSat 17 Jan 2009, 23:06 (18 years ago) parent5c15893
1 file changed+8−9
Data/Attoparsec/Incremental.hs+8−9
Data/Attoparsec/Incremental.hs+8−9
@@ -93,7 +93,8 @@ data Result a = Failed String
9393 | Partial (L.ByteString -> Result a)
9494 -- ^ The parse ran out of data before finishing. To
9595 -- resume the parse, pass more data to the given
96− -- continuation.
96+ -- continuation. To indicate that no more input is
97+ -- available, pass the empty string.
9798
9899instance (Show a) => Show (Result a) where
99100 show (Failed err) = "Failed " ++ show err
@@ -140,7 +141,8 @@ zero = fail ""
140141cutContinuation :: (a -> S -> IResult r) -> a -> S -> IResult r
141142cutContinuation k v s =
142143 case k v s of
143− IFailed (S lb i adds eof failDepth) err -> IFailed (S lb i adds eof (failDepth - 1)) err
144+ IFailed (S sb lb adds eof failDepth) err ->
145+ IFailed (S sb lb adds eof (failDepth - 1)) err
144146 x -> x
145147
146148appL :: L.ByteString -> L.ByteString -> L.ByteString
@@ -207,8 +209,10 @@ continue :: (S -> IResult r) -> Parser r a
207209continue onEOF p k (S _sb _lb adds eof failDepth) =
208210 if eof
209211 then onEOF (S S.empty L.empty adds True failDepth)
210− else IPartial $ \s -> let st = contState s adds failDepth
211− in unParser p st k
212+ else IPartial $ \s ->
213+ let st | L.null s = S S.empty L.empty adds True failDepth
214+ | otherwise = mkState s (addX s adds) False failDepth
215+ in unParser p st k
212216
213217takeWith :: (L.ByteString -> (L.ByteString, L.ByteString))
214218 -> Parser r L.ByteString
@@ -255,11 +259,6 @@ string s =
255259 st
256260 _ -> IFailed st "string failed to match"
257261
258−contState :: L.ByteString -> [L.ByteString] -> Int -> S
259−contState s adds failDepth
260− | L.null s = S S.empty L.empty [] True failDepth
261− | otherwise = mkState s (addX s adds) False failDepth
262−
263262-- | Match a single byte based on the given predicate.
264263satisfy :: (Word8 -> Bool) -> Parser r Word8
265264satisfy p =