Source

planck / pbuffer.mli

Full commit
(** Monadic parser for buffered char streams *)

open Sbuffer

(** Extend(Str)(Base) extends Base for Str with buffered string operations
    Typical usage is:

    module MyParser = struct
      module Base = ...(Str)... (* creation of Base *)
      include Base
      include Pbuffer.Extend(Str)(Base)
    end

    It includes the extensions of Pchar.Extend. If you use Pbuffer.Extend, 
    no need of using Pchar.Extend.

    See a use example in test/expr.ml
*)

module Extend(Sbuffer : sig
  include Stream_intf.S
  with type elem = char
  and  type Pos.t = Position.File.t
  val substr : t -> int -> int -> string * t
  val takeWhile : (char -> bool) -> t -> string * t
  val bytes : t -> int
end)(Base : Planck_intf.S 
     with type Str.elem = Sbuffer.elem
     and  type Str.attr = Sbuffer.attr
     and  type Str.Pos.t = Sbuffer.Pos.t) : sig

  (* CR jfuruse: we cannot write Base : Planck_intf.S with module Str = Sbuffer ! *)

  open Base

  val prefix : int -> string t
  (** fast retrieval of the prefix string of the given length *)

  val takeWhile : (char -> bool) -> string t
  val ( ??** ) : (char -> bool) -> string t
  val ( ??* ) : (char -> bool) -> unit t

  val string : string -> unit t
  (** Efficient version using Sbuffer. *)

  val chars_to_string : char list t -> string t

  val matched : unit t -> string t
  val with_matched : 'a t -> ('a * string) t
  val ( </> ) : 'a t -> 'a t -> 'a t
end