Kernel.AutomataSourceDFA construction and analysis for LR error pattern matching
This module implements a deterministic finite automaton (DFA) construction for analyzing failures of an LR automaton by consuming its stack.
Architecture:
K.derive to compute transitions, then partitions them by label equivalence (via IndexRefine.annotated_partition) to merge transitions with the same filter, captures, and usage.Hash-consing ensures canonical representation of equivalent DFA states.
The DFA states contain:
Order_chain for dynamically ordering continuations from the same branchRegister allocation is done lazily based on live ranges. The naive greedy allocation assigns registers according to variable classes, leading to less efficient but more minimizable ("factorizable") code.
The stacks type parameterizes the DFA construction with the actual stack topology, allowing the same construction to work over plain LR(1) states or refined LRC states.
type ('g, 'n) stacks = {domain : 'n Fix.Indexing.cardinal;Total number of stack positions.
*)tops : 'n Utils.Misc.indexset;Set of stack top positions — viable positions where the stack can end.
*)prev : 'n Fix.Indexing.index -> 'n Utils.Misc.indexset;For a given stack position, returns the set of predecessor positions that can transition to it in the LR automaton.
*)label : 'n Fix.Indexing.index -> 'g Info.lr1 Fix.Indexing.index;Returns the LR(1) state associated with a stack position.
*)}Stack topology abstraction for DFA construction.
Allows the same DFA construction to work over plain LR(1) states or refined LRC states.
val label_to_short_string :
'a Kernel__Info.grammar ->
'a Info.Lr1.n Utils.IndexSet.t ->
string