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_lalrpop::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§
Source§impl<'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> Freeze for Lexer<'t, T>
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§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more