Struct tokenate::InnerTokenizer
source · [−]pub struct InnerTokenizer<'a> { /* private fields */ }
Implementations
sourceimpl<'a> InnerTokenizer<'a>
impl<'a> InnerTokenizer<'a>
sourcepub fn peek(&mut self) -> Option<(usize, char)>
pub fn peek(&mut self) -> Option<(usize, char)>
Peek at the next char and index without moving forward
sourcepub fn peek_index(&mut self) -> usize
pub fn peek_index(&mut self) -> usize
Peek but you only need the index.
pub fn peek_pos(&mut self) -> Pos
sourcepub fn start_token(&mut self)
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)
sourcepub fn unpeek(&mut self)
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
sourcepub fn token_res<T>(&mut self, tt: T, unpeek: bool) -> TokenRes<'a, T>
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
pub fn make_token<T>(&mut self, value: T) -> Token<'a, T>
pub fn skip<CB: CharBool>(&mut self, cb: CB)
pub fn expected<T>(&mut self, s: String) -> TokenRes<'a, T>
pub fn expected_got<T>(&mut self, exp: String, got: String) -> TokenRes<'a, T>
pub fn consume_as<T, C: CharBool>(&mut self, c: C, t: T) -> TokenRes<'a, T>
sourcepub fn follow<T, C: CharBool>(&mut self, c: C, t: T) -> TokenRes<'a, T>
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
pub fn follow_or<T, C: CharBool>(
&mut self,
c: C,
t: T,
def: T
) -> TokenRes<'a, T>
sourcepub fn follow_fn<T, F: Fn(char) -> Result<T, String>>(
&mut self,
f: F
) -> TokenRes<'a, T>
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"),
})
sourcepub fn follow_fn_or<T, F: Fn(char) -> Option<T>>(
&mut self,
f: F,
def: T
) -> TokenRes<'a, T>
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
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> 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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
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