Struct GeneratorTokenQueue

Source
pub struct GeneratorTokenQueue<T, TData, TGeneratorState, TGenerator>
where T: TokenTrait, for<'a> TGenerator: FnMut(&mut TGeneratorState, &mut GeneratorTokenQueueBuffer<'a, T, TData>),
{ /* private fields */ }
Expand description

A token queue which has a backing generator/lexer which is called when needed by parsing logic

Implementations§

Source§

impl<T, TData, TGeneratorState, TGenerator> GeneratorTokenQueue<T, TData, TGeneratorState, TGenerator>
where T: TokenTrait, for<'a> TGenerator: FnMut(&mut TGeneratorState, &mut GeneratorTokenQueueBuffer<'a, T, TData>),

Source

pub fn new(generator: TGenerator, generator_state: TGeneratorState) -> Self

Create a new GeneratorTokenQueue with a lexer function and initial state

Trait Implementations§

Source§

impl<T, TData, TGeneratorState, TGenerator> TokenReader<T, TData> for GeneratorTokenQueue<T, TData, TGeneratorState, TGenerator>
where T: TokenTrait, TData: Debug, for<'a> TGenerator: FnMut(&mut TGeneratorState, &mut GeneratorTokenQueueBuffer<'a, T, TData>),

Source§

fn peek(&mut self) -> Option<&Token<T, TData>>

Returns a reference to next token but does not advance current position
Source§

fn peek_n(&mut self, n: usize) -> Option<&Token<T, TData>>

Returns a reference to nth (zero based) upcoming token without advancing
Source§

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

Returns the next token and advances
Source§

fn scan( &mut self, cb: impl FnMut(&T, &TData) -> bool, ) -> Option<&Token<T, TData>>

Runs the closure (cb) over upcoming tokens. Passes the value behind the Token to the closure. Will stop and return a reference to the next Token from when the closure returns true. Returns None if scanning finishes before closure returns true. Does not advance the reader. Read more
Source§

fn peek_mut(&mut self) -> Option<&mut Token<T, TData>>

Use with caution
Source§

fn conditional_next( &mut self, cb: impl FnOnce(&T) -> bool, ) -> Option<Token<T, TData>>

Returns next if cb returns true for the upcoming token (the token from TokenReader::peek)
Source§

fn expect_next( &mut self, expected_type: T, ) -> Result<TData, Option<(T, Token<T, TData>)>>

Tests that next token matches an expected type. Will return error if does not match. The Ok value contains the data of the valid token. Else it will return the Err with the expected token type and the token that did not match Read more

Auto Trait Implementations§

§

impl<T, TData, TGeneratorState, TGenerator> Freeze for GeneratorTokenQueue<T, TData, TGeneratorState, TGenerator>
where TGenerator: Freeze, TGeneratorState: Freeze,

§

impl<T, TData, TGeneratorState, TGenerator> RefUnwindSafe for GeneratorTokenQueue<T, TData, TGeneratorState, TGenerator>
where TGenerator: RefUnwindSafe, TGeneratorState: RefUnwindSafe, T: RefUnwindSafe, TData: RefUnwindSafe,

§

impl<T, TData, TGeneratorState, TGenerator> Send for GeneratorTokenQueue<T, TData, TGeneratorState, TGenerator>
where TGenerator: Send, TGeneratorState: Send, T: Send, TData: Send,

§

impl<T, TData, TGeneratorState, TGenerator> Sync for GeneratorTokenQueue<T, TData, TGeneratorState, TGenerator>
where TGenerator: Sync, TGeneratorState: Sync, T: Sync, TData: Sync,

§

impl<T, TData, TGeneratorState, TGenerator> Unpin for GeneratorTokenQueue<T, TData, TGeneratorState, TGenerator>
where TGenerator: Unpin, TGeneratorState: Unpin, T: Unpin, TData: Unpin,

§

impl<T, TData, TGeneratorState, TGenerator> UnwindSafe for GeneratorTokenQueue<T, TData, TGeneratorState, TGenerator>
where TGenerator: UnwindSafe, TGeneratorState: UnwindSafe, T: UnwindSafe, TData: 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.