Kernel.InfoSourceGrammar information interface
This module exports data structures and operations for handling grammar information. It provides indexed representations of grammars with type-level cardinalities for type-safe access.
Main components:
Load_grammar functor takes Menhir's grammar representation and computes all index structures for the grammar.terminal, nonterminal, symbol, production, itemlr0, lr1: LR(0) and LR(1) statesgoto_transition, shift_transition, transition: Transitionsreduction: ReductionsTerminal, Nonterminal, Symbol, Production, ItemLr0, Lr1, Transition, ReductionEach module provides:
cardinal: The size of the index setof_int: Construct an index from an integerExplicit representation of LR(0) items. An item is a production with a dot position: A -> α . β. Items are indexed globally across all productions for efficient set operations. The dot position ranges from 0 (before all RHS symbols) to length (after all).
LR(0) state information. LR(0) states represent the "core" of LR(1) states, ignoring lookahead information.
LR(1) state information. LR(1) states extend LR(0) cores with lookahead information, determining when reductions should be performed.
Reduction information. A reduction represents a (state, production, lookahead set) triple, meaning that in the given state, when the lookahead terminal is in the set, the parser should reduce by the given production.