[][src]Trait pear::input::Input

pub trait Input: Sized {
    type Token: Token<Self>;
    type Slice: Slice<Self>;
    type Many: Length;
    type Marker: Copy;
    type Context: Show;
    fn token(&mut self) -> Option<Self::Token>;
fn slice(&mut self, n: usize) -> Option<Self::Slice>;
fn peek<F>(&mut self, cond: F) -> bool
    where
        F: FnMut(&Self::Token) -> bool
;
fn peek_slice<F>(&mut self, n: usize, cond: F) -> bool
    where
        F: FnMut(&Self::Slice) -> bool
;
fn eat<F>(&mut self, cond: F) -> Option<Self::Token>
    where
        F: FnMut(&Self::Token) -> bool
;
fn eat_slice<F>(&mut self, n: usize, cond: F) -> Option<Self::Slice>
    where
        F: FnMut(&Self::Slice) -> bool
;
fn take<F>(&mut self, cond: F) -> Self::Many
    where
        F: FnMut(&Self::Token) -> bool
;
fn skip<F>(&mut self, cond: F) -> usize
    where
        F: FnMut(&Self::Token) -> bool
;
fn has(&mut self, n: usize) -> bool;
fn mark(&mut self, info: &ParserInfo) -> Self::Marker;
fn context(&mut self, _mark: Self::Marker) -> Self::Context; }

Associated Types

type Token: Token<Self>

type Slice: Slice<Self>

type Many: Length

type Marker: Copy

type Context: Show

Loading content...

Required methods

fn token(&mut self) -> Option<Self::Token>

Returns a copy of the current token, if there is one.

fn slice(&mut self, n: usize) -> Option<Self::Slice>

Returns a copy of the current slice of size n, if there is one.

fn peek<F>(&mut self, cond: F) -> bool where
    F: FnMut(&Self::Token) -> bool

Checks if the current token fulfills cond.

fn peek_slice<F>(&mut self, n: usize, cond: F) -> bool where
    F: FnMut(&Self::Slice) -> bool

Checks if the current slice of size n (if any) fulfills cond.

fn eat<F>(&mut self, cond: F) -> Option<Self::Token> where
    F: FnMut(&Self::Token) -> bool

Checks if the current token fulfills cond. If so, the token is consumed and returned. Otherwise, returns None.

fn eat_slice<F>(&mut self, n: usize, cond: F) -> Option<Self::Slice> where
    F: FnMut(&Self::Slice) -> bool

Checks if the current slice of size n (if any) fulfills cond. If so, the slice is consumed and returned. Otherwise, returns None.

fn take<F>(&mut self, cond: F) -> Self::Many where
    F: FnMut(&Self::Token) -> bool

Takes tokens while cond returns true, collecting them into a Self::Many and returning it.

fn skip<F>(&mut self, cond: F) -> usize where
    F: FnMut(&Self::Token) -> bool

Skips tokens while cond returns true. Returns the number of skipped tokens.

fn has(&mut self, n: usize) -> bool

Returns true if there are at least n tokens remaining.

fn mark(&mut self, info: &ParserInfo) -> Self::Marker

Emits a marker that represents the current parse position.

fn context(&mut self, _mark: Self::Marker) -> Self::Context

Returns a context to identify the input spanning from mark until but excluding the current position.

Loading content...

Implementations on Foreign Types

impl<'a> Input for &'a str[src]

type Token = char

type Slice = &'a str

type Many = Self::Slice

type Marker = &'a str

type Context = &'a str

fn token(&mut self) -> Option<Self::Token>[src]

Returns a copy of the current token, if there is one.

fn slice(&mut self, n: usize) -> Option<Self::Slice>[src]

Returns a copy of the current slice of size n, if there is one.

fn peek<F>(&mut self, cond: F) -> bool where
    F: FnMut(&Self::Token) -> bool
[src]

Checks if the current token fulfills cond.

fn peek_slice<F>(&mut self, n: usize, cond: F) -> bool where
    F: FnMut(&Self::Slice) -> bool
[src]

Checks if the current slice of size n (if any) fulfills cond.

fn eat<F>(&mut self, cond: F) -> Option<Self::Token> where
    F: FnMut(&Self::Token) -> bool
[src]

Checks if the current token fulfills cond. If so, the token is consumed and returned. Otherwise, returns None.

fn eat_slice<F>(&mut self, n: usize, cond: F) -> Option<Self::Slice> where
    F: FnMut(&Self::Slice) -> bool
[src]

Checks if the current slice of size n (if any) fulfills cond. If so, the slice is consumed and returned. Otherwise, returns None.

fn take<F>(&mut self, cond: F) -> Self::Many where
    F: FnMut(&Self::Token) -> bool
[src]

Takes tokens while cond returns true, collecting them into a Self::Many and returning it.

fn skip<F>(&mut self, cond: F) -> usize where
    F: FnMut(&Self::Token) -> bool
[src]

Skips tokens while cond returns true. Returns the number of skipped tokens.

fn has(&mut self, n: usize) -> bool[src]

Returns true if there are at least n tokens remaining.

Loading content...

Implementors

impl<'a> Input for Text<'a>[src]

type Token = char

type Slice = &'a str

type Many = Self::Slice

type Marker = usize

type Context = Span<'a>

fn token(&mut self) -> Option<Self::Token>[src]

Returns a copy of the current token, if there is one.

fn slice(&mut self, n: usize) -> Option<Self::Slice>[src]

Returns a copy of the current slice of size n, if there is one.

fn peek<F>(&mut self, cond: F) -> bool where
    F: FnMut(&Self::Token) -> bool
[src]

Checks if the current token fulfills cond.

fn peek_slice<F>(&mut self, n: usize, cond: F) -> bool where
    F: FnMut(&Self::Slice) -> bool
[src]

Checks if the current slice of size n (if any) fulfills cond.

fn eat<F>(&mut self, cond: F) -> Option<Self::Token> where
    F: FnMut(&Self::Token) -> bool
[src]

Checks if the current token fulfills cond. If so, the token is consumed and returned. Otherwise, returns None.

fn eat_slice<F>(&mut self, n: usize, cond: F) -> Option<Self::Slice> where
    F: FnMut(&Self::Slice) -> bool
[src]

Checks if the current slice of size n (if any) fulfills cond. If so, the slice is consumed and returned. Otherwise, returns None.

fn take<F>(&mut self, cond: F) -> Self::Many where
    F: FnMut(&Self::Token) -> bool
[src]

Takes tokens while cond returns true, collecting them into a Self::Many and returning it.

fn skip<F>(&mut self, cond: F) -> usize where
    F: FnMut(&Self::Token) -> bool
[src]

Skips tokens while cond returns true. Returns the number of skipped tokens.

fn has(&mut self, n: usize) -> bool[src]

Returns true if there are at least n tokens remaining.

impl<I: Input> Input for Pear<I>[src]

type Token = I::Token

type Slice = I::Slice

type Many = I::Many

type Marker = I::Marker

type Context = I::Context

impl<T: Indexable + Show + Length + PartialEq> Input for Cursor<T> where
    T::One: Show + PartialEq
[src]

type Token = T::One

type Slice = Extent<T>

type Many = Extent<T>

type Marker = usize

type Context = Extent<T>

fn token(&mut self) -> Option<Self::Token>[src]

Returns a copy of the current token, if there is one.

fn slice(&mut self, n: usize) -> Option<Self::Slice>[src]

Returns a copy of the current slice of size n, if there is one.

fn peek<F>(&mut self, cond: F) -> bool where
    F: FnMut(&Self::Token) -> bool
[src]

Checks if the current token fulfills cond.

fn peek_slice<F>(&mut self, n: usize, cond: F) -> bool where
    F: FnMut(&Self::Slice) -> bool
[src]

Checks if the current slice of size n (if any) fulfills cond.

fn eat<F>(&mut self, cond: F) -> Option<Self::Token> where
    F: FnMut(&Self::Token) -> bool
[src]

Checks if the current token fulfills cond. If so, the token is consumed and returned. Otherwise, returns None.

fn eat_slice<F>(&mut self, n: usize, cond: F) -> Option<Self::Slice> where
    F: FnMut(&Self::Slice) -> bool
[src]

Checks if the current slice of size n (if any) fulfills cond. If so, the slice is consumed and returned. Otherwise, returns None.

fn take<F>(&mut self, cond: F) -> Self::Many where
    F: FnMut(&Self::Token) -> bool
[src]

Takes tokens while cond returns true, collecting them into a Self::Many and returning it.

fn skip<F>(&mut self, cond: F) -> usize where
    F: FnMut(&Self::Token) -> bool
[src]

Skips tokens while cond returns true. Returns the number of skipped tokens.

fn has(&mut self, n: usize) -> bool[src]

Returns true if there are at least n tokens remaining.

fn context(&mut self, mark: Self::Marker) -> Self::Context[src]

Optionally returns a context to identify the current input position. By default, this method returns None, indicating that no context could be resolved.

Loading content...