package lrgrep
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=e53de12e4c5cbe6bca00643593266b4f9fa2e3f6a138195eeff7a4329f5c1c75
sha512=7fd7c4d11506fea7cc11c9bbf5aea9142d905643553c0c90e1bb16b794106b0c14a266acf89ae91b6929008dc0ba6515f788642873e2e4ba6c3d49bd45d25127
doc/kernel/Kernel/Automata/NFA/index.html
Module Automata.NFASource
type ('g, 'r) t = {uid : int;(*Unique identifier for graph visualization.
*)k : 'g Regexp.K.t;(*The continuation (derived regex state) represented by this NFA node.
*)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.
*)branch : ('g, 'r) Spec.branch Fix.Indexing.index;(*The branch (error pattern) this NFA state belongs to.
*)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).
val dump :
'a Kernel__Info.grammar ->
?only_forced:??? ->
('a, 'b) t ->
Stdlib.out_channel ->
unitDump NFA as a GraphViz dot file. only_forced controls whether to only include transitions whose lazy targets have been forced.
val make :
'g Info.grammar ->
'g Redgraph.graph ->
('g, 'a) Spec.branch Fix.Indexing.index ->
'g Regexp.K.t ->
('g, 'a) tBuild 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.
val from_branches :
'a Info.grammar ->
'a Redgraph.graph ->
('a, 'b) Spec.branches ->
(('a, 'b) Spec.branch, ('a, 'b) t) Fix.Indexing.Vector.tBuild 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).