Theory LR_Diag
theory LR_Diag
imports LR_Plain LR_Sparse LR_Vec
begin
section ‹Diagnosing a rejected word›
text ‹When the parser rejects a word, the diagnostics rerun its steps and stop
where the run fails. Nothing here is proved about errors: the parser's
result decides acceptance, and the diagnostics only describe a rejection.›
subsection ‹The error›
text ‹A set of columns as a list of intervals, ascending: ‹(a, Some b)› is
‹{a..b}›, ‹(a, None)› is ‹{a..}›.›
type_synonym colset = ‹(nat × nat option) list›
text ‹The kind of a failure: the step function has no action
(‹NoAction›), or the loop check finds a configuration that repeats between
two shifts (‹ReduceCycle›). On a layout grammar the offending token may be
accepted at another column: ‹Offside› when the accepted column nearest to
it lies in an interval unbounded to the right (it must be indented further, a
‹>› or ‹≥› relation), ‹Misaligned› when that interval is bounded (it
must be aligned, a ‹=› relation); each carries all accepted columns.›