Struct logos::Lexer

source ·
pub struct Lexer<Token: Logos, Source> {
    pub token: Token,
    pub extras: Token::Extras,
    /* private fields */
}
Expand description

Lexer is the main struct of the crate that allows you to read through a Source and produce tokens implementing the Logos trait.

Fields

token: Token

Current token. Call the advance method to get a new token.

extras: Token::Extras

Extras associated with the Token.

Implementations

Create a new Lexer.

Due to type inference, it might be more ergonomic to construct it by calling Token::lexer(source), where Token implements Logos.

Advance the Lexer and attempt to produce the next Token.

Get the range for the current token in Source.

Get a string slice of the current token.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.