Module Kernel.AutomataSource

DFA 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:

Hash-consing ensures canonical representation of equivalent DFA states.

The DFA states contain:

Register 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.

Sourcetype ('g, 'n) stacks = {
  1. domain : 'n Fix.Indexing.cardinal;
    (*

    Total number of stack positions.

    *)
  2. tops : 'n Utils.Misc.indexset;
    (*

    Set of stack top positions — viable positions where the stack can end.

    *)
  3. 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.

    *)
  4. 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.

Sourcetype priority = int
Sourceval label_to_short_string : 'a Kernel__Info.grammar -> 'a Info.Lr1.n Utils.IndexSet.t -> string
Sourceval string_of_cap : Regexp.Capture.t -> string
Sourcemodule NFA : sig ... end
Sourcemodule DFA : sig ... end
Sourcemodule Dataflow : sig ... end
Sourcemodule Machine : sig ... end