Skip to main content

ParseJob

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 borrows parse_interactive hands to the returned interactive parser (which retains the source and text; the table is Arc::cloned and owned, the postlex becomes an owned session). LexerSource is invariant (its Custom(&Mutex<dyn …>) arm), so 'i cannot shrink — which is exactly why it must not be shared with a short-lived start.
  • '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’s resolve_start produces a short-lived start local 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 str

The input to parse.

§start: &'s str

The start rule name.

§options: ParseOptions

Per-parse options (ParseOptions).

§postlex: Option<&'s dyn Postlex>

Optional streaming postlex (indenter) interposed between lexer and parser.

Trait Implementations§

§

impl<'i, 's> Clone for ParseJob<'i, 's>

§

fn clone(&self) -> ParseJob<'i, 's>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl<'i, 's> Copy for ParseJob<'i, 's>

Auto Trait Implementations§

§

impl<'i, 's> !RefUnwindSafe for ParseJob<'i, 's>

§

impl<'i, 's> !UnwindSafe for ParseJob<'i, 's>

§

impl<'i, 's> Freeze for ParseJob<'i, 's>

§

impl<'i, 's> Send for ParseJob<'i, 's>

§

impl<'i, 's> Sync for ParseJob<'i, 's>

§

impl<'i, 's> Unpin for ParseJob<'i, 's>

§

impl<'i, 's> UnsafeUnpin for ParseJob<'i, 's>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.