Skip to main content

read_balanced

Function read_balanced 

Source
pub fn read_balanced(
    expansion_level: ExpansionLevel,
    pack_parameters: bool,
    require_open: bool,
) -> Result<Tokens>
Expand description

Approximates TeX’s scan_toks (but doesn’t parse \def parameter lists) and only optionally requires the openning “{”.

It may return comments in the token lists. pack_parameters packs the # parameters of a macro body (Perl’s $macrodef, Tokens::pack_parameters). What happens when a file ends inside the read is the ScannerStatus’s business, not this flag’s: see read_definition_body and read_balanced_text for the scans that set one, and recover_at_file_end. If require_open is true, the opening T_BEGIN has not yet been read, and is required.

If toplevel is true, it will automatically close empty mouths as it reads, and will also fully expand macros (unless overridden by expansion_level being explicitly Off).