Trait mylex::Lex[][src]

pub trait Lex: Iterator where
    Self::Item: PartialEq
{ fn peek(&mut self) -> Self::Item; fn accept(&mut self, token: Self::Item) -> bool { ... }
fn accept_if(&mut self, filter: impl Fn(Self::Item) -> bool) -> bool { ... }
fn accept_while<T: Fn(Self::Item) -> bool>(&mut self, filter: T) -> bool { ... }
fn expect(&mut self, token: Self::Item) -> Result<(), Self::Item> { ... }
fn select_one<T, const N: usize>(
        &mut self,
        items: [(Self::Item, T); N]
    ) -> Option<T> { ... }
fn select_chain<T, const N: usize>(
        &mut self,
        items: [(Self::Item, T); N]
    ) -> Option<T> { ... } }

Trait for lexing any token stream.

Required methods

fn peek(&mut self) -> Self::Item[src]

Peek the current token.

Loading content...

Provided methods

fn accept(&mut self, token: Self::Item) -> bool[src]

Returns whether the current token is equal to token or not, and if it is equal, lexer moves to the next token.

fn accept_if(&mut self, filter: impl Fn(Self::Item) -> bool) -> bool[src]

Returns whether the current token passes the given filter or not, and if it does, lexer moves to the next token.

fn accept_while<T: Fn(Self::Item) -> bool>(&mut self, filter: T) -> bool[src]

Move the lexer to the next token while the current token passes the given filter. This function returns true only if at least one token passed the given filter.

fn expect(&mut self, token: Self::Item) -> Result<(), Self::Item>[src]

This function returns Ok and the lexer moves to the next token if token matches the current token. Otherwise returns the current token in an Err variant.

fn select_one<T, const N: usize>(
    &mut self,
    items: [(Self::Item, T); N]
) -> Option<T>
[src]

fn select_chain<T, const N: usize>(
    &mut self,
    items: [(Self::Item, T); N]
) -> Option<T>
[src]

Loading content...

Implementors

impl<'a> Lex for StrLexer<'a>[src]

Loading content...