Finite canonical LR(k) items #
This file supplies the finite data used by the canonical viable-prefix
automaton. Productions are represented by positions in the grammar's rule
list, rather than by their (possibly infinitely typed) nonterminals. Thus the
item and parser-state types are finite without imposing a Fintype instance on
the grammar's nonterminal type.
A production occurrence in the finite rule list.
Equations
Instances For
The production represented by a rule-list index.
Equations
- CF_grammar.LRk.ruleAt G i = G.rules.get i
Instances For
A dot position in a production, including the completed position just past the right-hand side.
Equations
- CF_grammar.LRk.Position G i = Fin ((CF_grammar.LRk.ruleAt G i).2.length + 1)
Instances For
Exactly k symbols of terminal lookahead. none is the explicit
end-of-input marker; after the first none, all semantically reachable
lookaheads are also none. Keeping the ambient function type unrestricted
makes finiteness immediate, while well-formedness is enforced by the semantic
relations below.
Equations
- CF_grammar.LRk.Lookahead T k = (Fin k → Option T)
Instances For
A canonical LR item [A → α · β, u].
The first component identifies the production, the second its dot position, and the third the padded terminal lookahead.
Equations
- CF_grammar.LRk.Item G k = ((i : CF_grammar.LRk.RuleIndex G) × CF_grammar.LRk.Position G i × CF_grammar.LRk.Lookahead T k)
Instances For
Equations
The production index of an item.
Instances For
The terminal lookahead of an item.
Instances For
Symbols before the dot.
Instances For
Symbols at and after the dot.
Instances For
An item is complete when its dot is just past the right-hand side.
Instances For
Relational dot advancement. A relational presentation avoids dependent casts between the position types while retaining a finite decidable relation.
Equations
Instances For
A lookahead v can follow a just-opened nonterminal when the remaining
sentential suffix is beta and the enclosing item has lookahead u.
This semantic FIRST_k relation is deliberately stated with rightmost
derivations. It is a finite decidable table by classical choice because its
arguments range over the finite item universe.
Equations
- CF_grammar.LRk.CanFollow G k beta u v = ∃ (z : List T), G.DerivesRightmost beta (List.map symbol.terminal z) ∧ CF_grammar.LRk.prependLookahead k z u = v
Instances For
One epsilon-closure edge between canonical items.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Epsilon closure of a finite item set.
Equations
- CF_grammar.LRk.closure G k I = {j : CF_grammar.LRk.Item G k | ∃ i ∈ I, Relation.ReflTransGen (CF_grammar.LRk.ClosureStep G k) i j}
Instances For
Canonical goto on one grammar symbol.
Equations
- CF_grammar.LRk.goto G k I X = {j : CF_grammar.LRk.Item G k | ∃ i ∈ CF_grammar.LRk.closure G k I, CF_grammar.LRk.Advances i X j}