pub fn recover_at_file_end() -> Result<FileEndRecovery>Expand description
A file has just ended under the current read: tex.web §362 closes it and
calls §336 check_outer_validity, which, when the ScannerStatus is not
normal, reports the runaway (§338 “File ended while scanning definition /
use / preamble / text of \cs”) and inserts the tokens that should lead to
recovery (§339).
Only an autoclose file level with an enclosing input ends like this: an
\input file, a file held in memory (filecontents, an \openout file),
catchfile’s opener (crate::mouth::Mouth::is_file_level). A package or
class read through reading_from_mouth (not autoclose) and the main
document keep Perl’s stop at their end; string mouths (\scantokens,
RawTeX) are no file levels (read_balanced crosses them).
defining,absorbing: a}— the definition or text ends at the file’s end and the enclosing input goes on;aligning:\crand}— the preamble, and with it the alignment, ends;matching: TeX inserts\parwithlong_state:=outer_call, andmacro_callabandons the call and drops its arguments on reading it (§392 “Report a runaway argument and abort”, which consumes the\par). Modelled without the token:FileEndRecovery::Abandonedmarksargument_runawayand the reader stops; the report and the file’s close wait for the call (abandon_runaway_call), which alone knows whether TeX would have stopped earlier, at a\par. Until then the ended file stays current, so a reader loop that does not look at the mark meets the same end again rather than reading on into the enclosing input.
The inserted tokens enter as ins_list inserts them, as input never
scanned (unread_expansion): the brace ledger counts the } when it is
read, which balances the definition’s opening {.