pub struct CommonTokenStream<S> { /* private fields */ }Implementations§
Source§impl<S> CommonTokenStream<S>where
S: TokenSource,
impl<S> CommonTokenStream<S>where
S: TokenSource,
Sourcepub const fn new(source: S) -> Self
pub const fn new(source: S) -> Self
Creates a token stream that filters lookahead to the default channel.
Sourcepub const fn with_channel(source: S, channel: i32) -> Self
pub const fn with_channel(source: S, channel: i32) -> Self
Creates a token stream whose LT/LA operations see only channel.
Sourcepub fn get(&mut self, index: usize) -> Option<&CommonToken>
pub fn get(&mut self, index: usize) -> Option<&CommonToken>
Returns the token at an absolute buffered index, fetching from the source as needed.
Sourcepub fn lt(&mut self, offset: isize) -> Option<&CommonToken>
pub fn lt(&mut self, offset: isize) -> Option<&CommonToken>
Returns the token at one-based lookahead/lookbehind offset, skipping tokens outside the configured channel for positive offsets.
pub fn lb(&self, offset: usize) -> Option<&CommonToken>
pub const fn token_source(&self) -> &S
pub fn tokens(&self) -> &[CommonToken]
Sourcepub fn previous_visible_token_index(&mut self, index: usize) -> Option<usize>
pub fn previous_visible_token_index(&mut self, index: usize) -> Option<usize>
Finds the previous buffered token visible to this stream before
index.
Parser rule intervals and $text actions are defined in terms of
visible tokens, but their rendered source text still includes hidden
tokens between the visible start and stop. Returning the previous token
on the stream channel avoids accidentally using trailing hidden
whitespace as the stop token.
Source§impl<S> CommonTokenStream<S>where
S: TokenSource,
impl<S> CommonTokenStream<S>where
S: TokenSource,
Trait Implementations§
Source§impl<S: Debug> Debug for CommonTokenStream<S>
impl<S: Debug> Debug for CommonTokenStream<S>
Source§impl<S> IntStream for CommonTokenStream<S>where
S: TokenSource,
impl<S> IntStream for CommonTokenStream<S>where
S: TokenSource,
Auto Trait Implementations§
impl<S> Freeze for CommonTokenStream<S>where
S: Freeze,
impl<S> RefUnwindSafe for CommonTokenStream<S>where
S: RefUnwindSafe,
impl<S> Send for CommonTokenStream<S>where
S: Send,
impl<S> Sync for CommonTokenStream<S>where
S: Sync,
impl<S> Unpin for CommonTokenStream<S>where
S: Unpin,
impl<S> UnsafeUnpin for CommonTokenStream<S>where
S: UnsafeUnpin,
impl<S> UnwindSafe for CommonTokenStream<S>where
S: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more