[][src]Struct molt::tokenizer::Tokenizer

pub struct Tokenizer<'a> { /* fields omitted */ }

The Tokenizer type. See the module-level documentation.

Methods

impl<'a> Tokenizer<'a>[src]

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

Creates a new tokenizer for the given input.

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

Returns the entire input.

pub fn as_str(&self) -> &str[src]

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

pub fn tail(&self, mark: usize) -> &str[src]

pub fn next(&mut self) -> Option<char>[src]

Returns the next character and updates the index.

pub fn peek(&mut self) -> Option<char>[src]

Returns the next character without updating the index.

pub fn token(&self, mark: usize) -> &str[src]

Get the token between the mark and the index. Returns "" if we're at the end or mark == index.

pub fn token2(&self, mark: usize, index: usize) -> &str[src]

Get the token between the mark and the index. Returns "" if mark == index.

pub fn is(&mut self, ch: char) -> bool[src]

Is the next character the given character? Does not update the index.

pub fn has<P>(&mut self, predicate: P) -> bool where
    P: Fn(&char) -> bool
[src]

Is the predicate true for the next character? Does not update the index.

pub fn at_end(&mut self) -> bool[src]

Is there anything left in the input?

pub fn skip(&mut self)[src]

Skip over the next character, updating the index. This is equivalent to next, but communicates better.

pub fn skip_char(&mut self, ch: char)[src]

Skip over the given character, updating the index. This is equivalent to next, but communicates better. Panics if the character is not matched.

pub fn skip_over(&mut self, num_chars: usize)[src]

Skips the given number of characters, updating the index. It is not an error if the iterator doesn't contain that many.

pub fn skip_while<P>(&mut self, predicate: P) where
    P: Fn(&char) -> bool
[src]

Skips over characters while the predicate is true. Updates the index.

pub fn backslash_subst(&mut self) -> char[src]

Parses a backslash-escape and returns its value. If the escape is valid, the value will be the substituted character. If the escape is not valid, it will be the single character following the backslash. Either way, the the index will point at what's next. If there's nothing following the backslash, return the backslash.

Trait Implementations

impl<'a> Clone for Tokenizer<'a>[src]

impl<'a> Debug for Tokenizer<'a>[src]

Auto Trait Implementations

impl<'a> Send for Tokenizer<'a>

impl<'a> Sync for Tokenizer<'a>

impl<'a> Unpin for Tokenizer<'a>

impl<'a> RefUnwindSafe for Tokenizer<'a>

impl<'a> UnwindSafe for Tokenizer<'a>

Blanket Implementations

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

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

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.

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

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

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