pub struct LexerSemCtx<'a, I>where
I: CharStream,{ /* private fields */ }Expand description
Runtime view passed to lexer semantic hooks.
Implementations§
Source§impl<'a, I> LexerSemCtx<'a, I>where
I: CharStream,
impl<'a, I> LexerSemCtx<'a, I>where
I: CharStream,
Sourcepub const fn rule_index(&self) -> usize
pub const fn rule_index(&self) -> usize
Lexer rule index that owns the predicate/action coordinate.
Sourcepub const fn coordinate_index(&self) -> usize
pub const fn coordinate_index(&self) -> usize
Predicate/action index inside the owning lexer rule.
Sourcepub const fn position(&self) -> usize
pub const fn position(&self) -> usize
Absolute input position where the predicate/action transition fired.
Sourcepub fn position_column(&self) -> usize
pub fn position_column(&self) -> usize
Source column at Self::position.
Sourcepub const fn token_start_column(&self) -> usize
pub const fn token_start_column(&self) -> usize
Column captured at the current token start.
Sourcepub fn text_so_far(&self) -> String
pub fn text_so_far(&self) -> String
Text matched from token start to this coordinate.
Sourcepub fn la(&mut self, offset: isize) -> i32
pub fn la(&mut self, offset: isize) -> i32
Character at a one-based lookahead/lookbehind offset.
Predicates read relative to their speculative ATN coordinate. Actions read relative to the committed input cursor, including characters consumed by an earlier action.
Sourcepub const fn token_start(&self) -> usize
pub const fn token_start(&self) -> usize
Absolute source index where the current token begins.
Sourcepub const fn token_type(&self) -> i32
pub const fn token_type(&self) -> i32
Pending type of the token being matched.
Sourcepub const fn set_type(&mut self, token_type: i32) -> bool
pub const fn set_type(&mut self, token_type: i32) -> bool
Sets the pending emitted token type. Action context only; see
Self::set_mode for the return value.
Sourcepub const fn set_channel(&mut self, channel: i32) -> bool
pub const fn set_channel(&mut self, channel: i32) -> bool
Sets the pending emitted token channel. Action context only; see
Self::set_mode for the return value.
Sourcepub fn consume(&mut self) -> bool
pub fn consume(&mut self) -> bool
Consumes one input character and updates source position tracking. Action context only; returns whether the operation was available.
Sourcepub const fn more(&mut self) -> bool
pub const fn more(&mut self) -> bool
Extends the current token with another lexer-rule match. Action context only.
Sourcepub fn reset_accept_position(&mut self, index: usize) -> bool
pub fn reset_accept_position(&mut self, index: usize) -> bool
Repositions the committed accept cursor. Action context only.
Sourcepub fn set_token_start(&mut self, index: usize) -> bool
pub fn set_token_start(&mut self, index: usize) -> bool
Moves the current token start forward within the committed match.
This is used after queueing a prefix token so automatic emission covers
only the remaining suffix. Returns false for predicate contexts or an
index outside the current token span.
Sourcepub fn enqueue_token(&mut self, token_type: i32, stop: usize) -> bool
pub fn enqueue_token(&mut self, token_type: i32, stop: usize) -> bool
Queues an additional token on the current channel.
The queued token spans the current token start through stop
(inclusive) and is returned before the match’s automatically emitted
token. Action context only.
Sourcepub fn enqueue_token_with_channel(
&mut self,
token_type: i32,
channel: i32,
stop: usize,
) -> bool
pub fn enqueue_token_with_channel( &mut self, token_type: i32, channel: i32, stop: usize, ) -> bool
Queues an additional token on an explicit channel. See
Self::enqueue_token.
Sourcepub fn set_mode(&mut self, mode: i32) -> bool
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).
Sourcepub fn push_mode(&mut self, mode: i32) -> bool
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.