Trait Parse

Source
pub trait Parse: Sized {
    // Required method
    fn parse(
        &self,
        input: &mut Context<impl Stream>,
    ) -> Result<Box<dyn Tree>, String>;

    // Provided method
    fn parse_stream<I: Stream>(self, input: I) -> ParseStream<Self, I> { ... }
}
Expand description

Parse a Stream.

Required Methods§

Source

fn parse( &self, input: &mut Context<impl Stream>, ) -> Result<Box<dyn Tree>, String>

Read input Trees from input and try to make a single output tree.

Special cases:

  • An unrecognised input tree should be passed on unchanged.
    • In particular, EndOfFile should be passed on unchanged. It must never be incorporated into a larger parse tree.
  • If this parser finds a parse error, abandon the current parse tree and return Err(message).
  • If input reports a parse error, abandon the current parse tree and pass on the error unchanged.
    • In particular, if input reports an incomplete file, pass it on.

Provided Methods§

Source

fn parse_stream<I: Stream>(self, input: I) -> ParseStream<Self, I>

Read Tokens from input to make a Stream of output Tokens.

To make each output Token, the returned Stream calls parse() to make a Tree, and annotates it with a Location.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl Parse for welly_parser::expr::Parser

Source§

impl Parse for welly_parser::lexer::Parser

Source§

impl Parse for welly_parser::stmt::Parser

Source§

impl Parse for welly_parser::word::Parser

Source§

impl<'a> Parse for &'a welly_parser::word::Parser