[−][src]Trait ttk91::parsing::Parser
Trait which provides convinience methods for parsers operating on SeekStreams of tokens and their Spans.
Associated Types
type Stream: SeekStream<Item = (T, Span)>
The token stream type on which the parser operates.
Required methods
fn stream(&self) -> &Self::Stream
Returns an immutable reference to the stream.
fn stream_mut(&mut self) -> &mut Self::Stream
Returns a mutable reference to the stream.
Provided methods
fn boundary_right(&mut self) -> usize
Returns the start offset of the next token. Can be used together with Parser::boundary_left to find the span of a token stream.
fn boundary_left(&mut self) -> usize
Returns the ending offset of the previous token. Can be used together with Parser::boundary_right to find the span of a token stream.
fn apply<P, O, C>(&mut self, op: P) -> Result<O, ParseError<C, T>> where
Self: Sized,
P: Operation<Self, O, C, T>,
Self: Sized,
P: Operation<Self, O, C, T>,
Applies the given parsing operation to the token stream, returning it's result. If the operation fails, reverts the token stream to its original position.
fn take_token<X>(&mut self, token: T) -> Result<T, ParseError<X, T>> where
T: Display + PartialEq,
Self: Sized,
T: Display + PartialEq,
Self: Sized,
Consumes the specified token from the token stream and returns it. If the next token in the stream is not the wanted token, returns an error.
fn assert_token<X>(&mut self, token: T) -> Result<(), ParseError<X, T>> where
T: Display + PartialEq,
Self: Sized,
T: Display + PartialEq,
Self: Sized,
Consumes the specified token from the token stream. If the next token in the stream is not the wanted token, returns an error.
Implementations on Foreign Types
impl<'_, P, T> Parser<T> for &'_ mut P where
P: Parser<T>,
[src]
P: Parser<T>,