Struct regex_lexer::Lexer
source · [−]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
sourceimpl<'t, T: 't> Lexer<'t, T>
impl<'t, T: 't> Lexer<'t, T>
sourcepub fn builder<'r>() -> LexerBuilder<'r, 't, T>
pub fn builder<'r>() -> LexerBuilder<'r, 't, T>
Create a LexerBuilder. This is the same as LexerBuilder::new.
Trait Implementations
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more