Preloading the canonical LR lookahead buffer #
On a properly endmarked input, the buffered DPDA deterministically reads
either k terminals or the earlier endmarker. The resulting parser control
contains exactly observe k w, and the remaining physical input is exactly
unreadAfter k w.
theorem
CF_grammar.LRk.Buffered.machine_reaches_preload
{T : Type}
[Fintype T]
(G : CF_grammar T)
(k : ℕ)
(hk : 0 < k)
(w : List T)
:
PDA.Reaches
{ state := (machine G k hk).initial_state, input := List.map some w ++ [none],
stack := [(machine G k hk).start_symbol] }
{ state := Control.parse (scanKernel G k []) (observe k w), input := unreadAfter k w, stack := [none] }
Exact preload theorem for a properly endmarked word.