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,
impl<'a, I> LexerLifecycleCtx<'a, I>where
I: CharStream,
Sourcepub const fn accept_position(&self) -> Option<usize>
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.
Sourcepub fn input_position(&self) -> usize
pub fn input_position(&self) -> usize
Current committed input position.
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_start_line(&self) -> usize
pub const fn token_start_line(&self) -> usize
Source line captured at the current token start.
Sourcepub const fn token_start_column(&self) -> usize
pub const fn token_start_column(&self) -> usize
Source column captured at the current token start.
Sourcepub const fn token_type(&self) -> i32
pub const fn token_type(&self) -> i32
Pending type of the token being matched.
Sourcepub fn pending_token_count(&self) -> usize
pub fn pending_token_count(&self) -> usize
Number of tokens waiting to be returned before another ATN match.
Sourcepub fn token_text(&self) -> String
pub fn token_text(&self) -> String
Text from the current token start through the committed input cursor.
Sourcepub fn accepted_text(&self) -> Option<String>
pub fn accepted_text(&self) -> Option<String>
Text selected by the original accepted ATN path.
Returns None outside the post-accept callback.
Sourcepub fn la(&mut self, offset: isize) -> i32
pub fn la(&mut self, offset: isize) -> i32
Character at a one-based lookahead/lookbehind offset from the committed input cursor.
Sourcepub const fn set_channel(&mut self, channel: i32)
pub const fn set_channel(&mut self, channel: i32)
Overrides the pending emitted token channel.
Sourcepub fn reset_accept_position(&mut self, index: usize)
pub fn reset_accept_position(&mut self, index: usize)
Repositions the committed accept cursor.
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.
Sourcepub fn enqueue_token(&mut self, token_type: i32, stop: usize)
pub fn enqueue_token(&mut self, token_type: i32, stop: usize)
Queues an additional token on the current channel.
Sourcepub fn enqueue_token_with_channel(
&mut self,
token_type: i32,
channel: i32,
stop: usize,
)
pub fn enqueue_token_with_channel( &mut self, token_type: i32, channel: i32, stop: usize, )
Queues an additional token on an explicit channel.