@@ -316,44 +316,46 @@ instance Functor (Initial s) where
316316-- is used for the next step.
317317--
318318-- If the result is 'SContinue', the parser driver retains the input in a
319- -- backtracking buffer, if the parser fails we may have to backtrack. If the
320- -- result is `SPartial` then the backtracking buffer is released i.e. we cannot
321- -- backtrack beyond this point in th stream. The parser must ensure that the
322- -- backtrack position is always after that.
319+ -- backtracking buffer, in case of failure the parser can backtrack up to the
320+ -- length of the backtracking buffer. Whenever the result is `SPartial` the
321+ -- current backtracking buffer is released i.e. we cannot backtrack beyond this
322+ -- point in the stream. The parser must ensure that the backtrack position is
323+ -- always within the bounds of the backtracking buffer.
323324--
324325-- If parser is not yet done, we can use the @extract@ operation on the @state@
325326-- of the parser to extract a result. If the parser has not yet yielded a
326- -- result, the extract fails with a 'ParseError' exception. If the parser
327- -- yielded a 'Partial' result in the past the latest partial result is
328- -- returned. Therefore, if a parser yields a partial result once it cannot fail
329- -- later on.
327+ -- result, @extract@ fails with a 'ParseError' exception. If the parser yielded
328+ -- a 'Partial' result in the past then the latest partial result is returned.
329+ -- Therefore, if a parser yields a partial result once it cannot fail later on.
330330--
331331-- /Pre-release/
332332--
333333{-# ANN type Step Fuse #-}
334334data Step s b =
335335 SPartial ! Int ! s
336- -- ^ @SPartial count state@. The following hold on Partial result:
336+ -- ^ @SPartial count state@. The following statements hold on an SPartial
337+ -- result:
337338 --
338339 -- 1. @extract@ on @state@ would succeed and give a result.
339- -- 2. Input stream position is reset to @current position + count@.
340+ -- 2. Input stream position is updated to @current position + count@.
340341 -- 3. All buffered input before the new position is dropped. The parser can
341- -- never backtrack beyond this position.
342+ -- never backtrack before this position.
342343
343344 | SContinue ! Int ! s
344- -- ^ @SContinue count state@. The following hold on a Continue result:
345+ -- ^ @SContinue count state@. The following statements hold on an SContinue
346+ -- result:
345347 --
346- -- 1. If there was a 'SPartial' result in past, @extract@ on @state@ would
347- -- give that result otherwise it may return 'Error' or 'SContinue'.
348- -- 2. Input stream position is reset to @current position + count@.
348+ -- 1. If 'SPartial' result was returned in the past, @extract@ on @state@
349+ -- would give that result otherwise it will return 'Error' or 'SContinue'.
350+ -- 2. Input stream position is updated to @current position + count@.
349351 -- 3. the previous input is retained in a backtrack buffer.
350352
351353 | SDone ! Int ! b
352354 -- ^ Done with leftover input count and result.
353355 --
354- -- @SDone count result@ means the parser has finished, it will accept no
355- -- more input, the final stream position must be set to @current position +
356- -- count@ and the result of the parser is in @result@.
356+ -- @SDone count result@ means the parser has finished, it will not accept
357+ -- any more input, the final stream position must be set to @current
358+ -- position + count@ and the result of the parser is in @result@.
357359
358360 | Error ! String
359361 -- ^ Parser failed without generating any output.
@@ -466,7 +468,7 @@ data Parser a m b =
466468 (m (Initial s b ))
467469 -- Extract can only return SPartial or SContinue n. In other words it
468470 -- can only backtrack or return partial result/error. But we do not
469- -- return result in Partial , therefore, we have to use SDone instead of
471+ -- return result in SPartial , therefore, we have to use SDone instead of
470472 -- SPartial.
471473 (s -> m (Step s b ))
472474
0 commit comments