TokenStream

Trait TokenStream 

Source
pub trait TokenStream<'input>: IntStream {
    type TF: TokenFactory<'input> + 'input;

    // Required methods
    fn lt(
        &mut self,
        k: isize,
    ) -> Option<&<Self::TF as TokenFactory<'input>>::Tok>;
    fn get(&self, index: isize) -> &<Self::TF as TokenFactory<'input>>::Tok;
    fn get_token_source(&self) -> &dyn TokenSource<'input, TF = Self::TF>;
    fn get_text_from_interval(&self, start: isize, stop: isize) -> String;

    // Provided methods
    fn get_all_text(&self) -> String { ... }
    fn get_text_from_tokens<T: Token + ?Sized>(&self, a: &T, b: &T) -> String
       where Self: Sized { ... }
}
Expand description

An IntSteam of Tokens

Used as an input for Parsers If there is an existing source of tokens, you should implement TokenSource, not TokenStream

Required Associated Types§

Source

type TF: TokenFactory<'input> + 'input

Token factory that created tokens in this stream

Required Methods§

Source

fn lt(&mut self, k: isize) -> Option<&<Self::TF as TokenFactory<'input>>::Tok>

Lookahead for tokens, same as IntSteam::la but return reference to full token

Source

fn get(&self, index: isize) -> &<Self::TF as TokenFactory<'input>>::Tok

Returns reference to token at index

Source

fn get_token_source(&self) -> &dyn TokenSource<'input, TF = Self::TF>

Token source that produced data for tokens for this stream

Source

fn get_text_from_interval(&self, start: isize, stop: isize) -> String

Get combined text of tokens in start..=stop interval

Provided Methods§

Source

fn get_all_text(&self) -> String

Get combined text of all tokens in this stream

Source

fn get_text_from_tokens<T: Token + ?Sized>(&self, a: &T, b: &T) -> String
where Self: Sized,

Get combined text of tokens in between a and b

Implementors§

Source§

impl<'input, T: TokenSource<'input>> TokenStream<'input> for CommonTokenStream<'input, T>

Source§

type TF = <T as TokenSource<'input>>::TF

Source§

impl<'input, T: TokenSource<'input>> TokenStream<'input> for UnbufferedTokenStream<'input, T>

Source§

type TF = <T as TokenSource<'input>>::TF