[][src]Struct sana::Lexer

pub struct Lexer<'input, Token: Sana + 'static> { /* fields omitted */ }

The Lexer is an Iterator of tokens

Implementations

impl<'input, Token: Sana> Lexer<'input, Token>[src]

pub fn new(input: &'input str) -> Self[src]

Create a new Lexer on the given input

NOTE: for better type inference it's prefered to use Sana::lexer instead

pub fn morph<Lexeme: Sana + 'static>(self) -> Lexer<'input, Lexeme>

Important traits for Lexer<'input, Token>

impl<'input, Token: Sana> Iterator for Lexer<'input, Token> type Item = Spanned<Token>;
[src]

Morth the lexer into another lexer, which scans a different token

The cursor position of the new lexer is the same as the cursor position of the old lexer before the metamorphosis

pub fn rewind(&mut self, pos: usize)[src]

Set the cursor at position pos

pub fn position(&self) -> usize[src]

The current position of the cursor

pub fn source(&self) -> &'input str[src]

The source string of the lexer

Trait Implementations

impl<'input, Token: Clone + Sana + 'static> Clone for Lexer<'input, Token>[src]

impl<'input, Token: Debug + Sana + 'static> Debug for Lexer<'input, Token>[src]

impl<'input, Token: Sana> Iterator for Lexer<'input, Token>[src]

type Item = Spanned<Token>

The type of the elements being iterated over.

Auto Trait Implementations

impl<'input, Token> RefUnwindSafe for Lexer<'input, Token> where
    Token: RefUnwindSafe

impl<'input, Token> Send for Lexer<'input, Token> where
    Token: Sync

impl<'input, Token> Sync for Lexer<'input, Token> where
    Token: Sync

impl<'input, Token> Unpin for Lexer<'input, Token>

impl<'input, Token> UnwindSafe for Lexer<'input, Token> where
    Token: RefUnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.