Skip to main content

LexerCapability

Trait LexerCapability 

Source
pub trait LexerCapability {
    type Token;

    // Required methods
    fn next_token(
        &mut self,
    ) -> Option<Result<(usize, Self::Token, usize), LexerError>>;
    fn peek_token(
        &mut self,
    ) -> Option<Result<(usize, Self::Token, usize), LexerError>>;
    fn position(&self) -> Range<usize>;
    fn source(&self) -> &str;
}
Expand description

Core lexer capability trait

Required Associated Types§

Source

type Token

Token type produced by this lexer

Required Methods§

Source

fn next_token( &mut self, ) -> Option<Result<(usize, Self::Token, usize), LexerError>>

Get the next token from the input

Source

fn peek_token( &mut self, ) -> Option<Result<(usize, Self::Token, usize), LexerError>>

Peek at the next token without consuming it

Source

fn position(&self) -> Range<usize>

Get the current position in the input

Source

fn source(&self) -> &str

Get source code reference

Implementors§