Skip to main content

LexerSemIrCtx

Struct LexerSemIrCtx 

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

SemIR evaluation adapter over a lexer, for grammar predicates and actions that the generator lowered into IR instead of a hook (issue #206).

Predicates get a shared borrow and evaluate at their speculative ATN coordinate, so lookahead and text-so-far are relative to position. Actions get a mutable borrow and run on the committed path, where mutating member state matches what a generated ANTLR lexer does in its own fields.

Implementations§

Source§

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

Source

pub const fn ctx_mut(&mut self) -> &mut LexerSemCtx<'a, I>

The underlying hook context, for callers that also dispatch hooks.

Trait Implementations§

Source§

impl<I> ActContext for LexerSemIrCtx<'_, I>
where I: CharStream,

Source§

fn set_return(&mut self, _name: &str, _value: i64)

A lexer rule has no return fields; ignore rather than inventing state.

Source§

fn set_member(&mut self, member: usize, value: i64)

Writes an integer member slot.
Source§

fn push_member(&mut self, member: usize, value: i64)

Pushes onto a stack-valued member slot. Read more
Source§

fn pop_member(&mut self, member: usize) -> Option<i64>

Pops a stack-valued member slot, returning the removed value. A no-op returning None when the stack is empty.
Source§

fn action_hook(&mut self, _hook: HookId)

Runs an externally implemented action hook.
Source§

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

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<I> PredContext for LexerSemIrCtx<'_, I>
where I: CharStream,

Source§

fn token_text(&mut self, _offset: isize) -> Option<Self::TokenText<'_>>

A lexer has no lookahead token; text predicates use crate::semir::PExpr::TokenTextSoFar instead.

Source§

fn hook(&mut self, _hook: HookId) -> bool

Hooks are dispatched by the caller, which owns the SemanticHooks object; an unrouted hook node declines rather than guessing.

Source§

type TokenText<'a> = String where Self: 'a

Source§

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

Token type (parser) or character (lexer) at the given lookahead.
Source§

fn token_index_adjacent(&mut self) -> bool

Whether LT(-2) and LT(-1) are adjacent token-stream entries.
Source§

fn ctx_rule_text(&self, _rule_index: usize) -> Option<String>

Text of the current context’s first child with this rule index.
Source§

fn member(&self, member: usize) -> Option<i64>

Integer member slot value.
Source§

fn member_top(&self, member: usize) -> Option<i64>

Top of a stack-valued member slot; None when empty or never pushed. Read more
Source§

fn member_len(&self, member: usize) -> usize

Depth of a stack-valued member slot.
Source§

fn local_arg(&self) -> Option<i64>

Integer argument of the current rule invocation.
Source§

fn column(&self) -> Option<i64>

Lexer current character position within the line.
Source§

fn token_start_column(&self) -> Option<i64>

Lexer character position of the current token’s start.
Source§

fn token_text_so_far(&self) -> Option<String>

Lexer text matched so far for the in-progress token.
Source§

fn trace_bool(&mut self, value: bool) -> bool

Reports an observable predicate-evaluation template and returns value.

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

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

§

impl<'a, I> UnsafeUnpin for LexerSemIrCtx<'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.