pub struct Lexer<K> { /* private fields */ }
Expand description
A regex-based lexer.
use regex_lexer::{LexerBuilder, Token};
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
enum Tok {
Ident,
// ...
}
let lexer = LexerBuilder::new()
.token(r"\p{XID_Start}\p{XID_Continue}*", Tok::Ident)
.ignore(r"\s+") // skip whitespace
// ...
.build()?;
let tokens = lexer.tokens("these are some identifiers");
Implementations§
Source§impl<K> Lexer<K>
impl<K> Lexer<K>
Sourcepub fn builder<'r>() -> LexerBuilder<'r, K>
pub fn builder<'r>() -> LexerBuilder<'r, K>
Create a LexerBuilder. This is the same as LexerBuilder::new.
Trait Implementations§
Auto Trait Implementations§
impl<K> Freeze for Lexer<K>
impl<K> RefUnwindSafe for Lexer<K>where
K: RefUnwindSafe,
impl<K> Send for Lexer<K>where
K: Send,
impl<K> Sync for Lexer<K>where
K: Sync,
impl<K> Unpin for Lexer<K>where
K: Unpin,
impl<K> UnwindSafe for Lexer<K>where
K: UnwindSafe,
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