Struct ParseJob
pub struct ParseJob<'i, 's> {
pub table: &'s Arc<ParseTable>,
pub lexer: LexerSource<'i>,
pub text: &'i str,
pub start: &'s str,
pub options: ParseOptions,
pub postlex: Option<&'s dyn Postlex>,
}Expand description
The invariant inputs to a parse — what to parse and how to lex it — bundled
so the six values that otherwise thread identically through every LALR entry
(parse_with, parse_discard, parse_interactive, and the private
[drive_to_accept]) travel as one. It is deliberately orthogonal to the
strategy — what each reduction yields (build a tree / discard / transform) —
which stays a separate argument (transform on parse_with, the reduce
mode inside [drive_to_accept]). That strategy axis is the one thing that
actually differs between the entries, so it is the one thing left un-bundled.
Copy (every field is): a job is only a bundle of borrows, so entries take
it by value. Note that nothing in-tree reuses one job across two entries —
the conformance tree vs. no-tree parity A/B deliberately builds two jobs,
because its custom lexer sources are stateful and must not share a cursor.
Two lifetimes, because the borrows split by how long they must live:
'i(input) —lexer+text: threaded through the whole parse, and the only borrowsparse_interactivehands to the returned interactive parser (which retains the source and text; the table isArc::cloned and owned, the postlex becomes an owned session).LexerSourceis invariant (itsCustom(&Mutex<dyn …>)arm), so'icannot shrink — which is exactly why it must not be shared with a short-livedstart.'s(setup) —table/start/postlex: read only at construction (table cloned into the state, start consumed building the state, postlex turned into an owned session). The facade’sresolve_startproduces a short-livedstartlocal that lives here, decoupled from the long invariant'i.
Fields§
§table: &'s Arc<ParseTable>The compiled parse table (the parse Arc::clones it into its state).
lexer: LexerSource<'i>Which lexer drives the parse (LexerSource: basic / contextual / custom).
text: &'i strThe input to parse.
start: &'s strThe start rule name.
options: ParseOptionsPer-parse options (ParseOptions).
postlex: Option<&'s dyn Postlex>Optional streaming postlex (indenter) interposed between lexer and parser.