pub struct Lexer<'a> { /* private fields */ }Expand description
Lexer for regex patterns.
Implementations§
Source§impl<'a> Lexer<'a>
impl<'a> Lexer<'a>
Sourcepub fn new_with_flags(input: &'a str, verbose: bool) -> Self
pub fn new_with_flags(input: &'a str, verbose: bool) -> Self
Create a new lexer with verbose mode.
Sourcepub fn set_position(&mut self, pos: usize)
pub fn set_position(&mut self, pos: usize)
Set the position in the input (for backtracking).
Sourcepub fn try_match(&mut self, s: &str) -> bool
pub fn try_match(&mut self, s: &str) -> bool
Try to match a specific string, advancing if successful.
This is useful for parser extensions that need to match multi-character sequences like keywords or specific syntax.
Sourcepub fn next_token(&mut self) -> Result<Token>
pub fn next_token(&mut self) -> Result<Token>
Sourcepub fn peek_token(&mut self) -> Result<Token>
pub fn peek_token(&mut self) -> Result<Token>
Peek at the next token without consuming it.
§Errors
Returns an error if an invalid escape sequence is encountered.
Auto Trait Implementations§
impl<'a> Freeze for Lexer<'a>
impl<'a> RefUnwindSafe for Lexer<'a>
impl<'a> Send for Lexer<'a>
impl<'a> Sync for Lexer<'a>
impl<'a> Unpin for Lexer<'a>
impl<'a> UnsafeUnpin for Lexer<'a>
impl<'a> UnwindSafe for Lexer<'a>
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