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,
impl<'a, I> LexerSemIrCtx<'a, I>where
I: CharStream,
Sourcepub const fn ctx_mut(&mut self) -> &mut LexerSemCtx<'a, I>
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,
impl<I> ActContext for LexerSemIrCtx<'_, I>where
I: CharStream,
Source§fn set_return(&mut self, _name: &str, _value: i64)
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)
fn set_member(&mut self, member: usize, value: i64)
Source§fn push_member(&mut self, member: usize, value: i64)
fn push_member(&mut self, member: usize, value: i64)
Source§fn pop_member(&mut self, member: usize) -> Option<i64>
fn pop_member(&mut self, member: usize) -> Option<i64>
None when the stack is empty.Source§fn action_hook(&mut self, _hook: HookId)
fn action_hook(&mut self, _hook: HookId)
Source§impl<'a, I> Debug for LexerSemIrCtx<'a, I>where
I: CharStream + Debug,
impl<'a, I> Debug for LexerSemIrCtx<'a, I>where
I: CharStream + Debug,
Source§impl<I> PredContext for LexerSemIrCtx<'_, I>where
I: CharStream,
impl<I> PredContext for LexerSemIrCtx<'_, I>where
I: CharStream,
Source§fn token_text(&mut self, _offset: isize) -> Option<Self::TokenText<'_>>
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
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.
type TokenText<'a> = String where Self: 'a
Source§fn la(&mut self, offset: isize) -> i64
fn la(&mut self, offset: isize) -> i64
Source§fn token_index_adjacent(&mut self) -> bool
fn token_index_adjacent(&mut self) -> bool
LT(-2) and LT(-1) are adjacent token-stream entries.Source§fn ctx_rule_text(&self, _rule_index: usize) -> Option<String>
fn ctx_rule_text(&self, _rule_index: usize) -> Option<String>
Source§fn member_top(&self, member: usize) -> Option<i64>
fn member_top(&self, member: usize) -> Option<i64>
None when empty or never pushed. Read moreSource§fn member_len(&self, member: usize) -> usize
fn member_len(&self, member: usize) -> usize
Source§fn token_start_column(&self) -> Option<i64>
fn token_start_column(&self) -> Option<i64>
Source§fn token_text_so_far(&self) -> Option<String>
fn token_text_so_far(&self) -> Option<String>
Source§fn trace_bool(&mut self, value: bool) -> bool
fn trace_bool(&mut self, value: bool) -> bool
value.