Trait TokenStream

Source
pub trait TokenStream {
    // Required methods
    fn advance(&mut self) -> bool;
    fn token(&self) -> &Token;
    fn token_mut(&mut self) -> &mut Token;

    // Provided methods
    fn next(&mut self) -> Option<&Token> { ... }
    fn process(&mut self, sink: &mut dyn FnMut(&Token)) { ... }
}
Expand description

TokenStream is the result of the tokenization.

It consists consumable stream of Tokens.

Required Methods§

Source

fn advance(&mut self) -> bool

Advance to the next token

Returns false if there are no other tokens.

Source

fn token(&self) -> &Token

Returns a reference to the current token.

Source

fn token_mut(&mut self) -> &mut Token

Returns a mutable reference to the current token.

Provided Methods§

Source

fn next(&mut self) -> Option<&Token>

Helper to iterate over tokens. It simply combines a call to .advance() and .token().

Source

fn process(&mut self, sink: &mut dyn FnMut(&Token))

Helper function to consume the entire TokenStream and push the tokens to a sink function.

Trait Implementations§

Source§

impl<'a> TokenStream for Box<dyn TokenStream + 'a>

Source§

fn advance(&mut self) -> bool

Advance to the next token Read more
Source§

fn token<'b>(&'b self) -> &'b Token

Returns a reference to the current token.
Source§

fn token_mut<'b>(&'b mut self) -> &'b mut Token

Returns a mutable reference to the current token.
Source§

fn next(&mut self) -> Option<&Token>

Helper to iterate over tokens. It simply combines a call to .advance() and .token().
Source§

fn process(&mut self, sink: &mut dyn FnMut(&Token))

Helper function to consume the entire TokenStream and push the tokens to a sink function.

Implementations on Foreign Types§

Source§

impl<'a> TokenStream for Box<dyn TokenStream + 'a>

Source§

fn advance(&mut self) -> bool

Source§

fn token<'b>(&'b self) -> &'b Token

Source§

fn token_mut<'b>(&'b mut self) -> &'b mut Token

Implementors§