Source

planck / lib / position.mli

open Spotlib.Spot

module type S = sig
  type t
  include Mtypes.Printable with type t := t
  val top : string -> t
  val none : t
end

module None : S with type t = unit

module File : sig
  type t = {
    fname  : string; (** file name *) 
    byte   : int;    (** in bytes from 0 *)
    line   : int;    (** from 1 *)
    column : int;    (** in bytes from 0 *)
  } with sexp

  include S with type t := t

  val add_newlines : t -> int -> t
  val add_columns  : t -> int -> t
  val format_detailed : Format.formatter -> t -> unit
end

module Region : sig
  type t = { start : File.t; end_ : File.t; } with sexp

  include S with type t := t

  val merge : [< `Between of t * t | `EndOf of t ] -> t
  (** [merge (`Between (p1, p2))] returns the position starts at the start point of [p1]
      and ends at the end point of [p2].

      [merge (`EndOf p)] returns the 0-length position starts and ends 
      at the end point of [p] 
  *)
end