Kernel.ReachabilitySourceReachability analysis for LR automata after conflict resolution
This module computes the reachability of states in a parser automaton after conflicts have been resolved (some transitions removed). It's used to reason about the actual behavior of the parser and compute minimal parsing costs.
Architecture:
The module uses:
Implementation details:
Classes module uses a refinement-based fixedpoint iteration to compute partitionings of terminals. Each SCC is processed in reverse topological order, using the current approximation for recursive occurrences.Coercion module implements the coerce matrices for changing between different partitionings. The infix function handles the special case where the last class is omitted (it has infinite cost).Tree module hash-conses the matrix DAG to avoid duplicates. The ConsedTree functor produces a tree where inner nodes represent matrix products and leaves represent individual transition costs.Cell module uses a clever bit-packing scheme to encode (node, pre_class, post_class) as a single integer, enabling efficient storage of large cost matrices.Solver module implements two analyses:Reverse_dependencies module tracks how changes to one cell affect others, enabling efficient incremental updates during the dataflow analysis.