Flag Separation for Indexed Grammars #
This file constructs a flag-separation transformation for indexed grammars.
This is Step 4 of Aho's Normal Form theorem.
Does this RHS symbol have a flag push?
Instances For
Lift an RHS symbol to the new nonterminal type, keeping flags.
Equations
- g.fsLiftRhsSym (IRhsSymbol.terminal t) = IRhsSymbol.terminal t
- g.fsLiftRhsSym (IRhsSymbol.nonterminal n f) = IRhsSymbol.nonterminal (Sum.inl n) f
Instances For
Replace a pushed nonterminal with a fresh intermediate (no push).
Equations
- g.fsReplaceRhsSym ruleIdx posIdx (IRhsSymbol.terminal t) = IRhsSymbol.terminal t
- g.fsReplaceRhsSym ruleIdx posIdx (IRhsSymbol.nonterminal n none) = IRhsSymbol.nonterminal (Sum.inl n) none
- g.fsReplaceRhsSym ruleIdx posIdx (IRhsSymbol.nonterminal a (some val)) = IRhsSymbol.nonterminal (Sum.inr (ruleIdx, posIdx)) none
Instances For
Strip flag push from an RHS symbol in the lifted type.
Equations
Instances For
Transform a single rule at index i into flag-separated rules.
Note: The consume check is done first (before the terminal check) to ensure
that rules with consume = some and terminal RHS are properly separated.
This is required for flagSeparate_flagsSeparated to hold.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The flag-separated grammar.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Properties #
Lift a sentential-form symbol.
Equations
Instances For
Project a sentential-form symbol.
Equations
Instances For
When hasPush is false, fsStripPushRhsSym agrees with fsLiftRhsSym on the list.
Simulation of a single rule: from the nonterminal with appropriate stack, flagSeparate can derive the lifted expansion.
Equations
- g.fsUnsepSym (IndexedGrammar.ISym.terminal t) = [IndexedGrammar.ISym.terminal t]
- g.fsUnsepSym (IndexedGrammar.ISym.indexed (Sum.inl n) σ) = [IndexedGrammar.ISym.indexed n σ]
- g.fsUnsepSym (IndexedGrammar.ISym.indexed (Sum.inr val) σ) = g.fsUnsepIntermediate val σ
Instances For
Equations
- g.fsUnsepSF w = List.flatMap g.fsUnsepSym w