Module Automata.NFASource

Sourcetype ('g, 'r) t = {
  1. uid : int;
    (*

    Unique identifier for graph visualization.

    *)
  2. k : 'g Regexp.K.t;
    (*

    The continuation (derived regex state) represented by this NFA node.

    *)
  3. transitions : ('g Regexp.Label.t * ('g, 'r) t lazy_t) list;
    (*

    Outgoing transitions, each tagged with a label (filter, captures, usage). Targets are lazy to avoid materializing unreachable states.

    *)
  4. branch : ('g, 'r) Spec.branch Fix.Indexing.index;
    (*

    The branch (error pattern) this NFA state belongs to.

    *)
  5. mutable mark : unit Stdlib.ref;
    (*

    Visitor mark for graph traversal and deduplication.

    *)
}

Nondeterministic finite automaton from regular expressions.

Transitions are lazy — NFA states are only materialized when explored during determinization. The make function returns a closure over the grammar, redgraph, and branch, producing NFA states on-demand from continuations (K.t).

Sourceval is_accepting : ('a, 'b) t -> bool
Sourceval dump : 'a Kernel__Info.grammar -> ?only_forced:??? -> ('a, 'b) t -> Stdlib.out_channel -> unit

Dump NFA as a GraphViz dot file. only_forced controls whether to only include transitions whose lazy targets have been forced.

Sourceval compare : ('a, 'b) t -> ('c, 'd) t -> int
Sourceval default_mark : unit Stdlib.ref
Sourceval uid : unit -> int
Sourceval make : 'g Info.grammar -> 'g Redgraph.graph -> ('g, 'a) Spec.branch Fix.Indexing.index -> 'g Regexp.K.t -> ('g, 'a) t

Build NFA state constructor for a given branch.

Returns a closure that, given a continuation k, produces the corresponding NFA state. Transitions are computed via K.derive, then partitioned by label equivalence using IndexRefine.annotated_partition to merge transitions sharing the same filter, captures, and usage. States are memoized using hash-consing on the continuation.

Sourceval from_branches : 'a Info.grammar -> 'a Redgraph.graph -> ('a, 'b) Spec.branches -> (('a, 'b) Spec.branch, ('a, 'b) t) Fix.Indexing.Vector.t

Build NFA states for all branches in branches.

For each branch, creates the initial NFA state from the branch's regular expression wrapped as K.More (re, K.Done).