pub struct Lexer<T: Tokenizer> { /* private fields */ }
Expand description
Provides machinery for splitting up an underlying sequence of items into a sequence of tokens, where each token can correspond to one or more items in the underlying sequence.
Implementations
sourceimpl<T: Tokenizer> Lexer<T>
impl<T: Tokenizer> Lexer<T>
sourcepub fn new(input: Vec<T::Item>, tokeniser: T) -> Self
pub fn new(input: Vec<T::Item>, tokeniser: T) -> Self
Construct a new lexer for a given string slice.
sourcepub fn get(&self, span: Span<T::Token>) -> &[T::Item]
pub fn get(&self, span: Span<T::Token>) -> &[T::Item]
Get the slice which corresponds to a given span from the underlying sequence.
sourcepub fn peek(&self) -> Span<T::Token>
pub fn peek(&self) -> Span<T::Token>
Peek at the next token in the sequence, or none if we have reached the end.
sourcepub fn next(&mut self) -> Span<T::Token>
pub fn next(&mut self) -> Span<T::Token>
Get the next token in the sequence, or none if we have reached the end.
Auto Trait Implementations
impl<T> RefUnwindSafe for Lexer<T>where
T: RefUnwindSafe,
<T as Tokenizer>::Item: RefUnwindSafe,
impl<T> Send for Lexer<T>where
T: Send,
<T as Tokenizer>::Item: Send,
impl<T> Sync for Lexer<T>where
T: Sync,
<T as Tokenizer>::Item: Sync,
impl<T> Unpin for Lexer<T>where
T: Unpin,
<T as Tokenizer>::Item: Unpin,
impl<T> UnwindSafe for Lexer<T>where
T: UnwindSafe,
<T as Tokenizer>::Item: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more