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,
impl<'a, I, F> LexerSemCtx<'a, I, F>where
I: CharStream,
F: TokenFactory,
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 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.