Skip to main content

CommonTokenStream

Struct CommonTokenStream 

Source
pub struct CommonTokenStream<S> { /* private fields */ }

Implementations§

Source§

impl<S> CommonTokenStream<S>
where S: TokenSource,

Source

pub const fn new(source: S) -> Self

Creates a token stream that filters lookahead to the default channel.

Source

pub const fn with_channel(source: S, channel: i32) -> Self

Creates a token stream whose LT/LA operations see only channel.

Source

pub fn fill(&mut self)

Reads tokens from the source until EOF is buffered.

Source

pub fn get(&mut self, index: usize) -> Option<&CommonToken>

Returns the token at an absolute buffered index, fetching from the source as needed.

Source

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.

Source

pub fn lb(&self, offset: usize) -> Option<&CommonToken>

Source

pub const fn token_source(&self) -> &S

Source

pub fn tokens(&self) -> &[CommonToken]

Source

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,

Source

pub fn la_token(&mut self, offset: isize) -> i32

Source

pub fn text(&mut self, start: usize, stop: usize) -> String

Source

pub fn drain_source_errors(&mut self) -> Vec<TokenSourceError>

Returns and clears diagnostics emitted by the underlying token source while this stream was fetching tokens.

Trait Implementations§

Source§

impl<S: Debug> Debug for CommonTokenStream<S>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<S> IntStream for CommonTokenStream<S>
where S: TokenSource,

Source§

fn consume(&mut self)

Source§

fn la(&mut self, offset: isize) -> i32

Source§

fn index(&self) -> usize

Source§

fn seek(&mut self, index: usize)

Source§

fn size(&self) -> usize

Source§

fn source_name(&self) -> &str

Source§

fn mark(&mut self) -> isize

Source§

fn release(&mut self, _marker: isize)

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.