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 fn new(source: S) -> Self

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

Use Self::try_new when token/source limit errors should be handled instead of reported as a construction panic.

Source

pub fn try_new(source: S) -> Result<Self, TokenStoreError>

Source

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

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

Source

pub fn try_with_channel( source: S, channel: i32, ) -> Result<Self, TokenStoreError>

Source

pub fn fill(&mut self)

Idempotent eager-buffering operation. Construction already buffers through EOF so the store can be shared with CST nodes.

Source

pub fn get(&self, index: usize) -> Option<TokenView<'_>>

Returns a borrowing view of the token at an absolute buffered index.

Source

pub fn get_id(&self, index: usize) -> Option<TokenId>

Returns the compact ID at an absolute buffered index.

Source

pub fn lt(&self, offset: isize) -> Option<TokenView<'_>>

Returns the token at one-based lookahead/lookbehind offset, skipping tokens outside the configured channel for positive offsets.

Source

pub fn lt_id(&self, offset: isize) -> Option<TokenId>

Returns the compact token ID at one-based lookahead/lookbehind offset.

Source

pub fn lb(&self, offset: usize) -> Option<TokenView<'_>>

Source

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

Source

pub fn tokens(&self) -> TokenIter<'_>

Iterates borrowing views of the original buffered token sequence.

Source

pub const fn token_count(&self) -> usize

Source

pub const fn token_store(&self) -> &TokenStore

Returns the canonical token store owned by this stream.

Source

pub fn into_token_store(self) -> TokenStore

Consumes the stream and returns its canonical token store.

Source

pub fn previous_visible_token_index(&self, index: usize) -> Option<usize>

Finds the previous buffered token visible to this stream before index.

Source§

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

Source

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

Source

pub fn token_type_at_index(&self, index: usize) -> i32

Returns the token type at a buffered absolute index. Past-EOF reads are reported as TOKEN_EOF.

Source

pub const fn channel(&self) -> i32

Returns the token channel visible to LT/LA operations.

Source

pub fn next_visible_after(&mut self, index: usize) -> usize

Returns the next parser-visible token index after consuming the token at index, skipping hidden-channel tokens.

Source

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

Source

pub fn text_all(&self) -> String

Concatenated text of every buffered token except EOF.

Source

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

Returns and clears diagnostics emitted while producing requested tokens.

Source

pub const fn is_filled(&self) -> bool

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>

§

impl<S> !RefUnwindSafe for CommonTokenStream<S>

§

impl<S> !Send for CommonTokenStream<S>

§

impl<S> !Sync for CommonTokenStream<S>

§

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.