ParserCtx

Struct ParserCtx 

Source
pub struct ParserCtx<L, D, U>
where L: Lexer<U>, D: ParserData,
{ pub lexer: L, pub tokens: Vec<L::Token>, pub states: Vec<D::StateID>, pub stats: ParserStats, }
Expand description

Core parser execution context.

ParserCtx manages the entire runtime state of the parser, including its lexer, parser states, token stack, and statistics. It is responsible for coordinating parsing operations, maintaining the parser stack, and collecting performance metrics.

§Type Parameters

  • L: The lexer type, which implements the Lexer trait.
  • D: The parser data definition, which implements the ParserData trait. This type is usually generated by the parlex-gen parser generator (ASLR).
  • U: User-defined data passed to parser and lexer actions.

Fields§

§lexer: L

The lexer instance used to produce tokens.

§tokens: Vec<L::Token>

The stack of tokens currently held by the parser.

§states: Vec<D::StateID>

The stack of parser state identifiers.

§stats: ParserStats

Statistics collected during parsing.

Implementations§

Source§

impl<L, D, U> ParserCtx<L, D, U>
where L: Lexer<U>, D: ParserData,

Implementation of ParserCtx methods.

This impl defines the core construction logic for the parser context. It provides methods to initialize a new parser context instance and set up the runtime environment for parsing, including token and state stacks and parser statistics.

§Type Parameters

  • L: The lexer type implementing the Lexer trait.
  • D: The parser data type implementing the ParserData trait. This type is usually generated by the parlex-gen parser generator (ASLR).
  • U: User-defined data passed to parser and lexer actions.
Source

pub fn new(lexer: L) -> Self

Constructs a new ParserCtx from the given lexer.

This initializes empty token and state stacks and resets parser statistics.

§Parameters
  • lexer: The lexer instance used to produce tokens for this parser.
§Returns

A fully initialized parser context ready for use.

Auto Trait Implementations§

§

impl<L, D, U> Freeze for ParserCtx<L, D, U>
where L: Freeze,

§

impl<L, D, U> RefUnwindSafe for ParserCtx<L, D, U>

§

impl<L, D, U> Send for ParserCtx<L, D, U>
where L: Send, <L as Lexer<U>>::Token: Send, <D as ParserData>::StateID: Send,

§

impl<L, D, U> Sync for ParserCtx<L, D, U>
where L: Sync, <L as Lexer<U>>::Token: Sync, <D as ParserData>::StateID: Sync,

§

impl<L, D, U> Unpin for ParserCtx<L, D, U>
where L: Unpin, <L as Lexer<U>>::Token: Unpin, <D as ParserData>::StateID: Unpin,

§

impl<L, D, U> UnwindSafe for ParserCtx<L, D, U>
where L: UnwindSafe, <L as Lexer<U>>::Token: UnwindSafe, <D as ParserData>::StateID: UnwindSafe,

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.