[][src]Struct regex_lexer::Lexer

pub struct Lexer<'t, T: 't> { /* fields omitted */ }

A regex-based lexer.

#[derive(Debug, PartialEq, Eq)]
enum Token<'t> {
    Ident(&'t str),
    // ...
}

let lexer = regex_lexer::LexerBuilder::new()
    .token(r"\p{XID_Start}\p{XID_Continue}*", |id| Some(Token::Ident(id)))
    .token(r"\s+", |_| None) // skip whitespace
    // ...
    .build()?;

let tokens = lexer.tokens("these are some identifiers");

Implementations

impl<'t, T: 't> Lexer<'t, T>[src]

pub fn builder<'r>() -> LexerBuilder<'r, 't, T>[src]

Create a LexerBuilder. This is the same as LexerBuilder::new.

pub fn tokens<'l>(&'l self, source: &'t str) -> Tokens<'l, 't, T>[src]

Return an iterator over all matched tokens.

Trait Implementations

impl<'t, T: 't> Debug for Lexer<'t, T>[src]

fn fmt(&self, f: &mut Formatter) -> Result[src]

Shows the original regular expressions

Auto Trait Implementations

impl<'t, T> !RefUnwindSafe for Lexer<'t, T>

impl<'t, T> !Send for Lexer<'t, T>

impl<'t, T> !Sync for Lexer<'t, T>

impl<'t, T> Unpin for Lexer<'t, T>

impl<'t, T> !UnwindSafe for Lexer<'t, T>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.