pub fn read_token_required(what: &str) -> Result<Option<Token>>Expand description
Read a token that the calling macro/primitive REQUIRES, holding the “argument expected but input ended” diagnostic in one place.
read_token() returning None (input exhausted) is a normal, expected
control-flow signal in most contexts (end of file/group/optional-arg scan) —
so the primitive deliberately keeps the Option. But for a caller that
genuinely requires a token here, None is TeX’s “File ended while scanning
use of \cs” error state (real pdftex raises an ! Emergency stop). This
helper emits that parity Error! once, centrally, instead of every call site
.unwrap()-panicking on the None. It STILL returns the Option (it does
NOT fabricate a token), so the type system keeps each caller honest about how
it degrades — close its group, substitute a default, etc.