mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 11:15:31 -05:00
some fixes related to review
This commit is contained in:
parent
b9828375e1
commit
8f9ecf5f41
2 changed files with 6 additions and 9 deletions
|
|
@ -531,8 +531,8 @@ let chars_fold ~f acc0 = {
|
||||||
| `Continue acc' ->
|
| `Continue acc' ->
|
||||||
incr i;
|
incr i;
|
||||||
acc := acc'
|
acc := acc'
|
||||||
| `Stop -> continue := false;
|
| `Stop a -> acc := a; continue := false;
|
||||||
| `Consume_and_stop -> incr i; continue := false
|
| `Consume_and_stop a -> acc := a; incr i; continue := false
|
||||||
| `Fail msg -> raise (Fold_fail (st,msg))
|
| `Fail msg -> raise (Fold_fail (st,msg))
|
||||||
)
|
)
|
||||||
done;
|
done;
|
||||||
|
|
|
||||||
|
|
@ -151,11 +151,8 @@ val ap : ('a -> 'b) t -> 'a t -> 'b t
|
||||||
val eoi : unit t
|
val eoi : unit t
|
||||||
(** Expect the end of input, fails otherwise. *)
|
(** Expect the end of input, fails otherwise. *)
|
||||||
|
|
||||||
val nop : unit t
|
|
||||||
(** Succeed with [()]. *)
|
|
||||||
|
|
||||||
val empty : unit t
|
val empty : unit t
|
||||||
(** Succeed with [()], same as {!nop}.
|
(** Succeed with [()].
|
||||||
@since NEXT_RELEASE *)
|
@since NEXT_RELEASE *)
|
||||||
|
|
||||||
val fail : string -> 'a t
|
val fail : string -> 'a t
|
||||||
|
|
@ -256,16 +253,16 @@ val set_current_slice : slice -> unit t
|
||||||
|
|
||||||
val chars_fold :
|
val chars_fold :
|
||||||
f:('acc -> char ->
|
f:('acc -> char ->
|
||||||
[`Continue of 'acc | `Consume_and_stop | `Stop | `Fail of string]) ->
|
[`Continue of 'acc | `Consume_and_stop of 'acc | `Stop of 'acc | `Fail of string]) ->
|
||||||
'acc ->
|
'acc ->
|
||||||
('acc * slice) t
|
('acc * slice) t
|
||||||
(** [chars_fold f acc0] folds over characters of the input.
|
(** [chars_fold f acc0] folds over characters of the input.
|
||||||
Each char [c] is passed, along with the current accumulator, to [f];
|
Each char [c] is passed, along with the current accumulator, to [f];
|
||||||
[f] can either:
|
[f] can either:
|
||||||
|
|
||||||
- stop, by returning [`Stop]. In this case the current accumulator
|
- stop, by returning [`Stop acc]. In this case the final accumulator [acc]
|
||||||
is returned, and [c] is not consumed.
|
is returned, and [c] is not consumed.
|
||||||
- consume char and stop, by returning [`Consume_and_stop].
|
- consume char and stop, by returning [`Consume_and_stop acc].
|
||||||
- fail, by returning [`Fail msg]. In this case the parser fails
|
- fail, by returning [`Fail msg]. In this case the parser fails
|
||||||
with the given message.
|
with the given message.
|
||||||
- continue, by returning [`Continue acc]. The parser continues to the
|
- continue, by returning [`Continue acc]. The parser continues to the
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue