Skip to main content

LexerSemCtx

Struct LexerSemCtx 

Source
pub struct LexerSemCtx<'a, I, F = CommonTokenFactory>
where I: CharStream, F: TokenFactory,
{ /* private fields */ }
Expand description

Runtime view passed to lexer semantic hooks.

Implementations§

Source§

impl<'a, I, F> LexerSemCtx<'a, I, F>
where I: CharStream, F: TokenFactory,

Source

pub const fn rule_index(&self) -> usize

Lexer rule index that owns the predicate/action coordinate.

Source

pub const fn coordinate_index(&self) -> usize

Predicate/action index inside the owning lexer rule.

Source

pub const fn position(&self) -> usize

Absolute input position where the predicate/action transition fired.

Source

pub fn mode(&self) -> i32

Lexer mode at this coordinate.

Source

pub const fn column(&self) -> usize

Current source column.

Source

pub fn position_column(&self) -> usize

Source column at Self::position.

Source

pub const fn token_start_column(&self) -> usize

Column captured at the current token start.

Source

pub fn text_so_far(&self) -> String

Text matched from token start to this coordinate.

Source

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

Sets the current lexer mode. Available only from a custom-action hook (the mutable-borrow context); a no-op with a warning path for the speculative predicate context, where mutating lexer state is invalid.

Returns true if the mutation was applied (action context), false if it was ignored (predicate context).

Source

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

Pushes the current mode and switches to mode. Action context only; see Self::set_mode for the return value.

Source

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

Pops the mode stack, restoring the previous mode. Action context only; returns the popped mode (None if the stack was empty or this is a predicate context).

Trait Implementations§

Source§

impl<'a, I, F> Debug for LexerSemCtx<'a, I, F>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a, I, F = CommonTokenFactory> !RefUnwindSafe for LexerSemCtx<'a, I, F>

§

impl<'a, I, F = CommonTokenFactory> !Send for LexerSemCtx<'a, I, F>

§

impl<'a, I, F = CommonTokenFactory> !Sync for LexerSemCtx<'a, I, F>

§

impl<'a, I, F = CommonTokenFactory> !UnwindSafe for LexerSemCtx<'a, I, F>

§

impl<'a, I, F> Freeze for LexerSemCtx<'a, I, F>

§

impl<'a, I, F> Unpin for LexerSemCtx<'a, I, F>

§

impl<'a, I, F> UnsafeUnpin for LexerSemCtx<'a, I, F>

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.