Skip to main content

Parser

Struct Parser 

Source
pub struct Parser<'eng, 'tokens> {
    pub tokens: Vec<Token<'tokens>>,
    pub meta: Arc<SourceMeta>,
    pub pos: usize,
    pub refs: RefMap,
    pub diag_engine: &'eng mut DiagnosticEngine<Code>,
    pub options: ParseOptions,
    pub source: Option<&'tokens str>,
    pub link_label_depth: u16,
    pub jsx_open_stack: Vec<String>,
}
Expand description

Token-stream cursor + diagnostic engine. 'tokens ties borrowed lexemes to the source; 'eng ties the engine borrow to the caller.

Fields§

§tokens: Vec<Token<'tokens>>§meta: Arc<SourceMeta>§pos: usize§refs: RefMap§diag_engine: &'eng mut DiagnosticEngine<Code>§options: ParseOptions§source: Option<&'tokens str>

Original source (with_source). Enables a provenance-correct byte-offset reslice in raw_source_for_token_range.

§link_label_depth: u16

Current [...] link-label nesting depth. Unresolved-shortcut replay is super-linear in this depth; above [MAX_LINK_LABEL_DEPTH] a [ becomes literal text. CM forbids links inside link text so this only bounds adversarial [[[[[... input.

§jsx_open_stack: Vec<String>

JSX elements currently being parsed (outermost first). parse_jsx pushes the open-tag name and pops on close. Inline / block collection consults this so a JsxCloseTagStart for an enclosing element terminates the run instead of leaking as literal text. Lowercase HTML tags never push here; only MDX component names.

Implementations§

Source§

impl<'eng, 'tokens> Parser<'eng, 'tokens>

Source

pub fn new( tokens: Vec<Token<'tokens>>, meta: Arc<SourceMeta>, diag_engine: &'eng mut DiagnosticEngine<Code>, ) -> Self

Source

pub fn new_with_options( tokens: Vec<Token<'tokens>>, meta: Arc<SourceMeta>, diag_engine: &'eng mut DiagnosticEngine<Code>, options: ParseOptions, ) -> Self

Source

pub fn with_source(self, source: &'tokens str) -> Self

Attach the original source so verbatim-slice reconstruction (raw HTML blocks, malformed-link bodies) can reslice it directly.

Source

pub fn parse(&mut self) -> Document

Drive the top-level loop until EOF. Force-advances on no-progress so a malformed token cannot wedge the cursor.

Auto Trait Implementations§

§

impl<'eng, 'tokens> Freeze for Parser<'eng, 'tokens>

§

impl<'eng, 'tokens> RefUnwindSafe for Parser<'eng, 'tokens>

§

impl<'eng, 'tokens> Send for Parser<'eng, 'tokens>

§

impl<'eng, 'tokens> Sync for Parser<'eng, 'tokens>

§

impl<'eng, 'tokens> Unpin for Parser<'eng, 'tokens>

§

impl<'eng, 'tokens> UnsafeUnpin for Parser<'eng, 'tokens>

§

impl<'eng, 'tokens> !UnwindSafe for Parser<'eng, 'tokens>

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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.