Skip to main content

LexerLifecycleCtx

Struct LexerLifecycleCtx 

Source
pub struct LexerLifecycleCtx<'a, I>
where I: CharStream,
{ /* private fields */ }
Expand description

Mutable lexer state exposed at lifecycle boundaries that have no ATN semantic coordinate.

The context is used before a token request starts matching, after an accepted path has applied its actions but before emission, and while a lexer is reset for reuse. Self::accept_position is present only at the post-accept boundary.

Implementations§

Source§

impl<'a, I> LexerLifecycleCtx<'a, I>
where I: CharStream,

Source

pub const fn accept_position(&self) -> Option<usize>

Original input boundary selected by the accepted ATN path.

A post-accept hook may move the committed cursor away from this boundary with Self::reset_accept_position.

Source

pub fn input_position(&self) -> usize

Current committed input position.

Source

pub const fn mode(&self) -> i32

Current lexer mode.

Source

pub const fn line(&self) -> usize

Current source line.

Source

pub const fn column(&self) -> usize

Current source column.

Source

pub const fn token_start(&self) -> usize

Absolute source index where the current token begins.

Source

pub const fn token_start_line(&self) -> usize

Source line captured at the current token start.

Source

pub const fn token_start_column(&self) -> usize

Source column captured at the current token start.

Source

pub const fn token_type(&self) -> i32

Pending type of the token being matched.

Source

pub const fn channel(&self) -> i32

Pending channel of the token being matched.

Source

pub fn pending_token_count(&self) -> usize

Number of tokens waiting to be returned before another ATN match.

Source

pub fn token_text(&self) -> String

Text from the current token start through the committed input cursor.

Source

pub fn accepted_text(&self) -> Option<String>

Text selected by the original accepted ATN path.

Returns None outside the post-accept callback.

Source

pub fn la(&mut self, offset: isize) -> i32

Character at a one-based lookahead/lookbehind offset from the committed input cursor.

Source

pub fn consume(&mut self)

Consumes one input character and updates source position tracking.

Source

pub const fn set_type(&mut self, token_type: i32)

Overrides the pending emitted token type.

Source

pub const fn set_channel(&mut self, channel: i32)

Overrides the pending emitted token channel.

Source

pub const fn skip(&mut self)

Marks the current match as skipped.

Source

pub const fn more(&mut self)

Extends the current token with another lexer-rule match.

Source

pub fn reset_accept_position(&mut self, index: usize)

Repositions the committed accept cursor.

Source

pub fn set_token_start(&mut self, index: usize) -> bool

Moves the current token start forward within the committed match.

Source

pub fn enqueue_token(&mut self, token_type: i32, stop: usize)

Queues an additional token on the current channel.

Source

pub fn enqueue_token_with_channel( &mut self, token_type: i32, channel: i32, stop: usize, )

Queues an additional token on an explicit channel.

Source

pub fn set_mode(&mut self, mode: i32)

Sets the current lexer mode.

Source

pub fn push_mode(&mut self, mode: i32)

Pushes the current mode and switches to mode.

Source

pub fn pop_mode(&mut self) -> Option<i32>

Pops the mode stack, restoring the previous mode.

Trait Implementations§

Source§

impl<'a, I> Debug for LexerLifecycleCtx<'a, I>
where I: CharStream + Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a, I> !RefUnwindSafe for LexerLifecycleCtx<'a, I>

§

impl<'a, I> !Send for LexerLifecycleCtx<'a, I>

§

impl<'a, I> !Sync for LexerLifecycleCtx<'a, I>

§

impl<'a, I> !UnwindSafe for LexerLifecycleCtx<'a, I>

§

impl<'a, I> Freeze for LexerLifecycleCtx<'a, I>

§

impl<'a, I> Unpin for LexerLifecycleCtx<'a, I>

§

impl<'a, I> UnsafeUnpin for LexerLifecycleCtx<'a, I>

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.