Finite canonical LR action table #
Canonical parser states are the raw finite kernels stored on the parse stack; their epsilon closure is inspected for actions. Reduction has priority in the total table definition. On reachable states LR(k) uniqueness proves that the arbitrary finite choice of a complete item cannot affect the selected grammar rule.
Finite raw states of the canonical viable-prefix automaton.
Equations
Instances For
A complete item enabled in a raw state at the displayed lookahead.
Equations
- CF_grammar.LRk.EnabledReduction G k q u i = (i ∈ CF_grammar.LRk.closure G.augment k q ∧ i.Complete ∧ i.lookahead = u)
Instances For
Choose one enabled reduction item. The choice is deliberately finite and noncomputable: automata in this repository are mathematical transition functions, and LR(k) uniqueness later proves rule-independence.
Equations
- CF_grammar.LRk.reductionItem? G k q u = if h : ∃ (i : CF_grammar.LRk.Item G.augment k), CF_grammar.LRk.EnabledReduction G k q u i then some (Classical.choose h) else none
Instances For
A terminal is syntactically shift-supported when some closed item has it immediately after the dot. The total table below safely defaults to shifting whenever no semantic reduction is enabled; this predicate remains useful for the usual canonical-item characterization of reachable shifts.
Equations
- CF_grammar.LRk.ShiftEnabled G k q a = ∃ i ∈ CF_grammar.LRk.closure G.augment k q, i.next? = some (symbol.terminal a)
Instances For
Total finite action selected by a canonical table.
- shift {T : Type} {G : CF_grammar T} : TableAction G
- reduce {T : Type} {G : CF_grammar T} (rule : RuleIndex G.augment) : TableAction G
- accept {T : Type} {G : CF_grammar T} : TableAction G
- error {T : Type} {G : CF_grammar T} : TableAction G
Instances For
First buffered symbol, returning EOF for the degenerate zero-lookahead
buffer. The final construction uses k+1, so its reachable buffers are
always nondegenerate.
Instances For
Canonical table action. A completed augmented-start item is acceptance; all other completed items are reductions. If there is no reduction, a syntactically enabled terminal is shifted.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The raw goto state used after shifting or reducing a grammar symbol.
Equations
- CF_grammar.LRk.nextKernel G k q X = CF_grammar.LRk.goto G.augment k q X
Instances For
On a reachable state, every chosen complete item is a semantic reduction candidate at the corresponding scanned prefix.
If a particular semantic reduction is exposed in a reachable state, the finite table chooses an item naming the same production value.