Skip to main content

Lexer

Struct Lexer 

Source
pub struct Lexer<'lex> { /* private fields */ }
Expand description

Produces Tokens from an input string.

Implementations§

Source§

impl<'lex> Lexer<'lex>

Source

pub fn new(input: &str, offset: BytePos) -> Lexer<'_>

Creates a new Lexer to read tokens from the input string.

Source

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.

Source

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.

Source

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V