Xeger. Random
(Xeger v0.1.0)
View Source
Generates a single random string matching an AST, without enumerating the full match set: makes one random choice at each node (which alternative, how many repeats, which codepoint) instead of walking every possibility.
Threads an explicit :rand state through generation rather than touching
the process's global :rand state, so Xeger.random/2's :seed option
is reproducible without side-affecting unrelated code sharing the same
process.
An unbounded :rep node (*, +, {m,}) draws its repeat count
uniformly from min..opts[:max_repeat] when given. Without :max_repeat
there's no upper bound to draw uniformly from, so each repeat beyond the
pattern's own minimum is instead a coin flip (p = 0.5) on whether to
continue -- unbounded in principle, geometrically distributed (so almost
surely short) in practice.
Summary
Functions
@spec generate(Xeger.AST.t(), keyword(), :rand.state()) :: {binary(), :rand.state()}