Source

planck / lib / stoken.mli

(** Create a stream from a result of a parser *)

open Spotlib.Spot

module type S = sig

  module Under : Planck_intf.S

  module Elem : Elem.S
  module Pos : Position.S
  module Attr : sig
    type t
    val position      : t -> Pos.t
    val last_position : t -> Pos.t option
    val memo          : t -> Smemo.memo
  end

  include Stream_intf.X with type elem := Elem.t
                        and  type pos  := Pos.t
                        and  type attr := Attr.t

  (* CR jfuruse: Elem, Pos and Attr are overridden by restricted ones by this inclusion! *)
  include Smemo.X with type stream := t

  val create : (Elem.t option * Pos.t) Under.t -> Under.Str.t -> t
  val last_position : t -> Pos.t option
end

module Make(E: Elem.S)(Pos: Position.S)(P : sig
  include Planck_intf.S
  val run : 'a t -> Str.t -> ('a * Str.t, error) Result.t
end) : S with type Elem.t = E.t
         and  type Pos.t  = Pos.t
         and  type 'a Under.t = 'a P.t
         and  type Under.Str.desc = P.Str.desc