[−][src]Trait pear::input::Input
Associated Types
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,
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,
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,
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,
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,
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,
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.
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]
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,
[src]
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,
[src]
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,
[src]
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,
[src]
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,
[src]
F: FnMut(&Self::Token) -> bool,
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 mark(&mut self, _info: &ParserInfo) -> Self::Marker
[src]
fn context(&mut self, mark: Self::Marker) -> Self::Context
[src]
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]
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,
[src]
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,
[src]
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,
[src]
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,
[src]
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,
[src]
F: FnMut(&Self::Token) -> bool,
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 mark(&mut self, _: &ParserInfo) -> Self::Marker
[src]
fn context(&mut self, mark: Self::Marker) -> Self::Context
[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]
T::One: Show + PartialEq,
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]
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,
[src]
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,
[src]
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,
[src]
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,
[src]
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,
[src]
F: FnMut(&Self::Token) -> bool,
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 mark(&mut self, _: &ParserInfo) -> Self::Marker
[src]
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.