pub trait Logos<'source>: Sized {
type Extras;
type Source: Source + ?Sized + 'source;
const ERROR: Self;
fn lex(lexer: &mut Lexer<'source, Self>);
fn lexer(source: &'source Self::Source) -> Lexer<'source, Self>ⓘNotable traits for Lexer<'source, Token>impl<'source, Token> Iterator for Lexer<'source, Token> where
Token: Logos<'source>, type Item = Token;
where
Self::Extras: Default,
{ ... }
fn lexer_with_extras(
source: &'source Self::Source,
extras: Self::Extras
) -> Lexer<'source, Self>ⓘNotable traits for Lexer<'source, Token>impl<'source, Token> Iterator for Lexer<'source, Token> where
Token: Logos<'source>, type Item = Token;
{ ... }
}
Expand description
Trait implemented for an enum representing all tokens. You should never have
to implement it manually, use the #[derive(Logos)]
attribute on your enum.
Associated Types
Associated type Extras
for the particular lexer. This can be set using
#[logos(extras = MyExtras)]
and accessed inside callbacks.
Associated Constants
Required methods
Provided methods
Create a new instance of a Lexer
that will produce tokens implementing
this Logos
.
Create a new instance of a Lexer
with the provided Extras
that will
produce tokens implementing this Logos
.