Expand description
Located, error-recovering parsers for .text streams and header
declarations.
parse_text and parse_declarations accept exactly the inputs that
ParsedModule::parse_section and
HeaderDeclarations accept, but keep the byte span of every instruction,
symbol definition, and declaration, and keep going after a malformed
statement so that every problem is reported as a human-readable
SyntaxError.
Both split their block into statements first (see
statements): one statement per line, continued onto
following lines only inside an open bracket. Each statement is parsed on
its own, so recovery is per line and every bad line is reported once.
Spans are byte ranges relative to the parsed block.
Structs§
- Parsed
Declarations - Located header declarations and every syntax error.
- Parsed
Text - A located
.textstream: instructions in address order, symbol definitions in source order, and every syntax error. - Spanned
- A parsed value and the byte range of its source text.
- Syntax
Error - A located, human-readable syntax error.
Functions§
- line_
column - The 1-based line and column (counted in characters) of
offsetintext. - parse_
declarations - Parse header declarations, one per statement, keeping spans and recovering after malformed declarations.
- parse_
declarations_ at parse_declarationsfor a block that starts on file linefirst_line.- parse_
text - Parse a
.textstream, keeping spans and recovering after malformed statements. - parse_
text_ at parse_textfor a block that starts on file linefirst_line.