package regenerate

  1. Overview
  2. Docs

Parameters

module Word : Word.S
module Segment : Segments.S with type elt = Word.t
module Sigma : sig ... end

Signature

module Word = Word
module Segment = Segment
type node =
  1. | Nothing
  2. | Everything
  3. | Cons of Segment.t * lang

Spline of a language, a cascade-like thunk list with multiple nils.

and lang = unit -> node

Utilities

val segmentEpsilon : Segment.t
val nothing : unit -> node
val everything : unit -> node
val (@:) : Segment.t -> lang -> unit -> node
val langEpsilon : unit -> node
module IMap : sig ... end
module Sigma_star : sig ... end

Precomputed full language. Used to replace "Everything" when need

val pp_item : Segment.t Fmt.t
val pp : Format.formatter -> lang -> unit
val of_list : Word.t list -> unit -> node

Classic operations

val union : (unit -> node) -> (unit -> node) -> unit -> node
val inter : (unit -> node) -> (unit -> node) -> unit -> node
val difference_aux : int -> (unit -> node) -> (unit -> node) -> unit -> node
val difference : (unit -> node) -> (unit -> node) -> unit -> node
val compl : (unit -> node) -> unit -> node

Concatenation

Invariants for each language:

  • nbSeg = List.length indices
  • After explode_head, CCVector.size vec >= n
  • if bound = Some n then n >= nbSeg and seqₙ = Nothing.
val explode_head : (Segment.t, CCVector.rw) CCVector.t -> ((unit -> node) * int option * int * int list) -> int -> (unit -> node) * int option * int * int list
val concat_subterms_of_length : n:int -> f:(a:'a -> 'b -> Segment.t) -> int list -> ('a, 'c) CCVector.t -> ('b, 'd) CCVector.t -> Segment.t
val combine_segments_left : n:int -> int list -> (Segment.t, 'a) CCVector.t -> (Segment.t, 'b) CCVector.t -> Segment.t
val combine_segments_right : n:int -> (Segment.t, 'a) CCVector.t -> int list -> (Segment.t, 'b) CCVector.t -> Segment.t
val concatenate : (unit -> node) -> (unit -> node) -> unit -> node

Star

val star_subterms_of_length : max:int -> (int * Segment.t) list -> Segment.t IMap.t -> Segment.t
val star : (unit -> node) -> unit -> node
val add_epsilonX : int -> (unit -> node) -> unit -> node
val dec : int -> int
val rep_with_acc : (unit -> node) -> int -> int CCOpt.t -> (unit -> node) -> unit -> node
val rep : int -> int CCOpt.t -> (unit -> node) -> unit -> node

Others

val charset : bool -> Word.char list -> unit -> node
val gen : Word.char Regex.t -> lang

Exporting

val flatten_from : int -> (unit -> node) -> (Segment.elt -> unit) -> unit
val flatten : (unit -> node) -> (Segment.elt -> unit) -> unit
type res =
  1. | Done
  2. | Finite
  3. | GaveUp
exception ExitSample

sample ~skip ~n lang returns a sequence of on average n elements. lang is only consumed when needed.

We sample one element every k, where k follows a power law of average skip. Furthermore, if we consume more than sqrt k empty segments, we assume that the rest of the segments will be infinitely empty and stop.

If firsts is provided, we always output the firsts first elements.

val sample : ?st:Random.State.t -> ?n:int -> ?firsts:int -> skip:int -> (unit -> node) -> (Segment.elt -> unit) -> res