sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>
On This Page
Regenerate is a library to generate test cases for regular expression engines.
Here is a typical use of the library, for creating a test harness with QCheck
.
let test =
(* The alphabet is [abc] *)
let alphabet = ['a'; 'b'; 'c'] in
(* Words are made of regular strings. *)
let module Word = Regenerate.Word.String in
(* Streams are made of ThunkLists. *)
let module Stream = Regenerate.Segments.ThunkList(Word) in
let generator =
Regenerate.arbitrary
(module Word)
(module Stream)
~compl:false (* Do not generate complement operators. *)
~pp:Fmt.char (* Printer for characters. *)
~samples:100 (* We want on average 100 samples for each regex. *)
alphabet
in
QCheck.Test.make generator check (* Test the [check] function. *)
type 'a regex = 'a Regex.t
The type of regular expressions on characters of type 'a
.
val arbitrary :
(module Word.S with type char = 'char and type t = 'word) ->
(module Segments.S with type elt = 'word) ->
?skip:int ->
compl:bool ->
pp:'char Fmt.t ->
samples:int ->
'char list ->
('char Regex.t * 'word list * 'word list) QCheck.arbitrary
Regenerate.arbitrary (module W) (module S) ~compl ~pp ~samples alpha
creates a QCheck
generator that generates triples containing a regex
and a list of positive and negative samples.
val parse :
string ->
(char regex, [> `Not_supported | `Parse_error ]) Stdlib.result
Regenerate.parse s
returns the associated regex
. It recognizes the Posix Extended Regular Expression syntax plus complement (~a
) and intersection (a&b
). Character classes are not supported.
module Regex : sig ... end
Definition of Regular expressions and associated utilities.
module Word : sig ... end
Generic definitions of words on which regular expression can match.
module Segments = Segments
Streaming data-structures that will contain the generate samples.
This API allows full access to generators and regular operators. For casual use of the library, consider using arbitrary
instead.
module type SIGMA = sig ... end
module Make
(Word : Word.S)
(Segment : Segments.S with type elt = Word.t)
(Sigma : SIGMA with type t = Segment.t) :
sig ... end
Regenerate.Make(W)(S)(A)
is a module that implements sample generation for words implemented by the module W
with the alphabet A
. S
describes the data structure used internally for the enumeration of words.