pub struct Lexer<'lex> { /* private fields */ }Expand description
Produces Tokens from an input string.
Implementations§
Source§impl<'lex> Lexer<'lex>
impl<'lex> Lexer<'lex>
Sourcepub fn new(input: &str, offset: BytePos) -> Lexer<'_>
pub fn new(input: &str, offset: BytePos) -> Lexer<'_>
Creates a new Lexer to read tokens from the input string.
Sourcepub fn next_token(&mut self) -> Result<(Span, Token<'lex>), ParseError>
pub fn next_token(&mut self) -> Result<(Span, Token<'lex>), ParseError>
Scans the input stream for the next token, returning the token and the span of input text from which it was scanned.
Sourcepub fn skip_shebang(&mut self)
pub fn skip_shebang(&mut self)
Skips over a shebang line at the start of input. This is used when
parsing files which, on Unix systems, may use a line consisting of #!
followed by a path to the interpreter.
§Panics
Panics if any tokens have already been scanned from the input stream.
Sourcepub fn current_position(&self) -> BytePos
pub fn current_position(&self) -> BytePos
Returns the current position within the input string.
The next call to next_token will begin searching at this point.
Auto Trait Implementations§
impl<'lex> Freeze for Lexer<'lex>
impl<'lex> RefUnwindSafe for Lexer<'lex>
impl<'lex> Send for Lexer<'lex>
impl<'lex> Sync for Lexer<'lex>
impl<'lex> Unpin for Lexer<'lex>
impl<'lex> UnsafeUnpin for Lexer<'lex>
impl<'lex> UnwindSafe for Lexer<'lex>
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