package lrgrep
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=e53de12e4c5cbe6bca00643593266b4f9fa2e3f6a138195eeff7a4329f5c1c75
sha512=7fd7c4d11506fea7cc11c9bbf5aea9142d905643553c0c90e1bb16b794106b0c14a266acf89ae91b6929008dc0ba6515f788642873e2e4ba6c3d49bd45d25127
doc/kernel/Kernel/Automata/DFA/index.html
Module Automata.DFASource
type ('src, 'tgt) mapping =
('tgt, 'src Fix.Indexing.index * (Regexp.Capture.set * Utils.Usage.set))
Fix.Indexing.vectorMapping from target kernel positions to (source position, captures, usage).
For each position in the target state's kernel, records which position in the source state's kernel it came from, along with the set of captures and usages associated with that transition.
type ('g, 'r, 'dfa, 'n) state = {index : 'dfa Fix.Indexing.index;branches : ('n, ('g, 'r) Spec.branch Fix.Indexing.index) Fix.Indexing.vector;(*Branch index for each position in the kernel.
*)accepting : 'n Utils.Boolvector.t;(*Which kernel positions correspond to accepting NFA states.
*)mutable transitions : ('g, 'r, 'dfa, 'n) transition list;(*Outgoing transitions, populated during determinization.
*)
}DFA state.
Each state has a kernel of NFA states ordered by branch priority, a vector of branch indices, and a boolean vector marking which kernel positions are accepting.
and ('g, 'r, 'dfa, 'src) transition = | Transition : {label : 'g Info.lr1 Utils.Misc.indexset;(*Set of LR(1) states that trigger this transition.
*)target : ('g, 'r, 'dfa, 'tgt) state;(*The target DFA state.
*)mapping : ('src, 'tgt) mapping;(*Maps each target kernel position to its source kernel position and the associated captures/usage.
*)
} -> ('g, 'r, 'dfa, 'src) transition
DFA transition with a label (set of LR1 states), a target state, and a mapping from target kernel positions back to source positions.
Erased-phantom packed state, used for vector storage.
type ('g, 'r, 'dfa) t = {initial : 'dfa Fix.Indexing.index;(*Index of the initial state.
*)states : ('dfa, ('g, 'r, 'dfa) packed) Fix.Indexing.vector;(*All DFA states indexed by their DFA index.
*)domain : ('dfa, 'g Info.lr1 Utils.Misc.indexset) Fix.Indexing.vector;(*For each state, the set of LR(1) states for which there exists a reachable stack that can reach this state.
*)kernels : ('dfa, ('g, 'r) NFA.t array) Fix.Indexing.vector;(*For each state, the array of NFA states in its kernel (ordered by priority).
*)
}Complete DFA with all states, transitions, and kernel information.
val dump :
'a Kernel__Info.grammar ->
('a, 'b, 'c) t ->
'a Redgraph.graph ->
Stdlib.out_channel ->
unitErased-phantom existential wrapper for the DFA.
val determinize :
'g Info.grammar ->
('g, 'r) Spec.branches ->
('g, 's) stacks ->
('a, ('g, 'r) NFA.t) Fix.Indexing.Vector.t ->
('g, 'r) _tDeterminize NFA branches into a DFA using modified power set construction.
Takes the grammar, error pattern branches, stack topology, and the initial stack position. Returns a DFA where states are hash-consed by their kernel (ordered array of NFA states). Only transitions corresponding to reachable LR stacks are constructed.