pub struct Lexer<'t, T: 't> { /* private fields */ }
Expand description

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

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

Return an iterator over all matched tokens.

Trait Implementations

Shows the original regular expressions

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.