pub trait Input: Sized {
type Token: Token<Self>;
type Slice: Slice<Self>;
type Many: Length;
type Marker: Copy;
type Context: Show;
// Required methods
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;
}
Required Associated Types§
type Token: Token<Self>
type Slice: Slice<Self>
type Many: Length
type Marker: Copy
type Context: Show
Required Methods§
sourcefn token(&mut self) -> Option<Self::Token>
fn token(&mut self) -> Option<Self::Token>
Returns a copy of the current token, if there is one.
sourcefn slice(&mut self, n: usize) -> Option<Self::Slice>
fn slice(&mut self, n: usize) -> Option<Self::Slice>
Returns a copy of the current slice of size n
, if there is one.
sourcefn peek_slice<F>(&mut self, n: usize, cond: F) -> bool
fn peek_slice<F>(&mut self, n: usize, cond: F) -> bool
Checks if the current slice of size n
(if any) fulfills cond
.
sourcefn eat<F>(&mut self, cond: F) -> Option<Self::Token>
fn eat<F>(&mut self, cond: F) -> Option<Self::Token>
Checks if the current token fulfills cond
. If so, the token is
consumed and returned. Otherwise, returns None
.
sourcefn eat_slice<F>(&mut self, n: usize, cond: F) -> Option<Self::Slice>
fn eat_slice<F>(&mut self, n: usize, cond: F) -> Option<Self::Slice>
Checks if the current slice of size n
(if any) fulfills cond
. If so,
the slice is consumed and returned. Otherwise, returns None
.
sourcefn take<F>(&mut self, cond: F) -> Self::Many
fn take<F>(&mut self, cond: F) -> Self::Many
Takes tokens while cond
returns true, collecting them into a
Self::Many
and returning it.
sourcefn skip<F>(&mut self, cond: F) -> usize
fn skip<F>(&mut self, cond: F) -> usize
Skips tokens while cond
returns true. Returns the number of skipped
tokens.
sourcefn mark(&mut self, info: &ParserInfo) -> Self::Marker
fn mark(&mut self, info: &ParserInfo) -> Self::Marker
Emits a marker that represents the current parse position.
Object Safety§
Implementations on Foreign Types§
source§impl<'a> Input for &'a str
impl<'a> Input for &'a str
source§fn token(&mut self) -> Option<Self::Token>
fn token(&mut self) -> Option<Self::Token>
Returns a copy of the current token, if there is one.
source§fn slice(&mut self, n: usize) -> Option<Self::Slice>
fn slice(&mut self, n: usize) -> Option<Self::Slice>
Returns a copy of the current slice of size n
, if there is one.
source§fn peek_slice<F>(&mut self, n: usize, cond: F) -> bool
fn peek_slice<F>(&mut self, n: usize, cond: F) -> bool
Checks if the current slice of size n
(if any) fulfills cond
.
source§fn eat<F>(&mut self, cond: F) -> Option<Self::Token>
fn eat<F>(&mut self, cond: F) -> Option<Self::Token>
Checks if the current token fulfills cond
. If so, the token is
consumed and returned. Otherwise, returns None
.
source§fn eat_slice<F>(&mut self, n: usize, cond: F) -> Option<Self::Slice>
fn eat_slice<F>(&mut self, n: usize, cond: F) -> Option<Self::Slice>
Checks if the current slice of size n
(if any) fulfills cond
. If so,
the slice is consumed and returned. Otherwise, returns None
.
source§fn take<F>(&mut self, cond: F) -> Self::Many
fn take<F>(&mut self, cond: F) -> Self::Many
Takes tokens while cond
returns true, collecting them into a
Self::Many
and returning it.
source§fn skip<F>(&mut self, cond: F) -> usize
fn skip<F>(&mut self, cond: F) -> usize
Skips tokens while cond
returns true. Returns the number of skipped
tokens.