[][src]Trait ttk91::parsing::Parser

pub trait Parser<T> {
    type Stream: SeekStream<Item = (T, Span)>;
    fn stream(&self) -> &Self::Stream;
fn stream_mut(&mut self) -> &mut Self::Stream; fn boundary_right(&mut self) -> usize { ... }
fn boundary_left(&mut self) -> usize { ... }
fn apply<P, O, C>(&mut self, op: P) -> Result<O, ParseError<C, T>>
    where
        Self: Sized,
        P: Operation<Self, O, C, T>
, { ... }
fn take_token<X>(&mut self, token: T) -> Result<T, ParseError<X, T>>
    where
        T: Display + PartialEq,
        Self: Sized
, { ... }
fn assert_token<X>(&mut self, token: T) -> Result<(), ParseError<X, T>>
    where
        T: Display + PartialEq,
        Self: Sized
, { ... } }

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.

Loading content...

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.

Loading content...

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>, 

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

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

Consumes the specified token from the token stream. If the next token in the stream is not the wanted token, returns an error.

Loading content...

Implementations on Foreign Types

impl<'_, P, T> Parser<T> for &'_ mut P where
    P: Parser<T>, 
[src]

type Stream = P::Stream

Loading content...

Implementors

impl<'a, T> Parser<Token<'a>> for Parser<'a, T>[src]

type Stream = BufferedStream<SpannedIter<'a, Token<'a>>>

Loading content...