Trait pear::input::Input [−][src]
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
Required methods
fn token(&mut self) -> Option<Self::Token>
[src]
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]
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]
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]
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]
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]
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]
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.
Implementations on Foreign Types
impl<'a> Input for &'a str
[src]
impl<'a> Input for &'a str
[src]fn token(&mut self) -> Option<Self::Token>
[src]
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]
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]
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]
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]
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]
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]
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.
Implementors
impl<'a> Input for Text<'a>
[src]
impl<'a> Input for Text<'a>
[src]fn token(&mut self) -> Option<Self::Token>
[src]
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]
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]
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]
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]
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]
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]
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.
impl<I: Input> Input for Pear<I>
[src]
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
fn token(&mut self) -> Option<Self::Token>
[src]
fn slice(&mut self, n: usize) -> Option<Self::Slice>
[src]
fn has(&mut self, n: usize) -> bool
[src]
fn peek<F>(&mut self, cond: F) -> bool where
F: FnMut(&Self::Token) -> bool,
[src]
F: FnMut(&Self::Token) -> bool,
fn peek_slice<F>(&mut self, n: usize, cond: F) -> bool where
F: FnMut(&Self::Slice) -> bool,
[src]
F: FnMut(&Self::Slice) -> bool,
fn eat<F>(&mut self, cond: F) -> Option<Self::Token> where
F: FnMut(&Self::Token) -> bool,
[src]
F: FnMut(&Self::Token) -> bool,
fn eat_slice<F>(&mut self, n: usize, cond: F) -> Option<Self::Slice> where
F: FnMut(&Self::Slice) -> bool,
[src]
F: FnMut(&Self::Slice) -> bool,
fn take<F>(&mut self, cond: F) -> Self::Many where
F: FnMut(&Self::Token) -> bool,
[src]
F: FnMut(&Self::Token) -> bool,
fn skip<F>(&mut self, cond: F) -> usize where
F: FnMut(&Self::Token) -> bool,
[src]
F: FnMut(&Self::Token) -> bool,
fn mark(&mut self, info: &ParserInfo) -> Self::Marker
[src]
fn context(&mut self, mark: Self::Marker) -> Self::Context
[src]
impl<T: Indexable + Show + Length + PartialEq> Input for Cursor<T> where
T::One: Show + PartialEq,
[src]
impl<T: Indexable + Show + Length + PartialEq> Input for Cursor<T> where
T::One: Show + PartialEq,
[src]fn token(&mut self) -> Option<Self::Token>
[src]
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]
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]
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]
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]
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]
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]
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]
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.