InnerTokenizer

Struct InnerTokenizer 

Source
pub struct InnerTokenizer<'a> { /* private fields */ }

Implementations§

Source§

impl<'a> InnerTokenizer<'a>

Source

pub fn new(s: &'a str) -> Self

Create a new InnerTokenizer

Source

pub fn next(&mut self) -> Option<(usize, char)>

Get the next char and it’s index

Source

pub fn peek(&mut self) -> Option<(usize, char)>

Peek at the next char and index without moving forward

Source

pub fn peek_char(&mut self) -> Option<char>

Peek, but you don’t care about the index

Source

pub fn peek_index(&mut self) -> usize

Peek but you only need the index.

Source

pub fn peek_pos(&mut self) -> Pos

Source

pub fn start_token(&mut self)

Call before creating a token, marks the start before reading it (token_res calls this ready for the next token, but it is safe to do again)

Source

pub fn unpeek(&mut self)

Drop the current peek and make sure new lines and stuff are counted This guarantees the following call to next (or peek) will be new

Source

pub fn token_res<T>(&mut self, tt: T, unpeek: bool) -> TokenRes<'a, T>

Build a TokenRes from the status of the with the string of the current value unpeek should be true if the last peeked character is part if the current token

Source

pub fn make_token<T>(&mut self, value: T) -> Token<'a, T>

Source

pub fn skip<CB: CharBool>(&mut self, cb: CB)

Source

pub fn expected<T>(&mut self, s: String) -> TokenRes<'a, T>

Source

pub fn expected_got<T>(&mut self, exp: String, got: String) -> TokenRes<'a, T>

Source

pub fn consume_as<T, C: CharBool>(&mut self, c: C, t: T) -> TokenRes<'a, T>

Source

pub fn follow<T, C: CharBool>(&mut self, c: C, t: T) -> TokenRes<'a, T>

When an item must be followed by a specific character to give a fixed result

Source

pub fn follow_or<T, C: CharBool>( &mut self, c: C, t: T, def: T, ) -> TokenRes<'a, T>

Source

pub fn follow_fn<T, F: Fn(char) -> Result<T, String>>( &mut self, f: F, ) -> TokenRes<'a, T>

When an item must be followed by a set of options which could produce different results

// after an equals
tok.follow_fn(|c|match c {
    '>'=>Ok(MyToken::Arrow),
    '='=>Ok(MyToken::EqEq),
    _=>Err("Equals Needs a GT or another Equals"),
})
Source

pub fn follow_fn_or<T, F: Fn(char) -> Option<T>>( &mut self, f: F, def: T, ) -> TokenRes<'a, T>

When an item may be followed by a specific character

Source

pub fn take_while<T, CB: CharBool, F: Fn(&str) -> Result<T, String>>( &mut self, cb: CB, f: F, ) -> TokenRes<'a, T>

Auto Trait Implementations§

§

impl<'a> Freeze for InnerTokenizer<'a>

§

impl<'a> RefUnwindSafe for InnerTokenizer<'a>

§

impl<'a> Send for InnerTokenizer<'a>

§

impl<'a> Sync for InnerTokenizer<'a>

§

impl<'a> Unpin for InnerTokenizer<'a>

§

impl<'a> UnwindSafe for InnerTokenizer<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.