welly_parser

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.

Object Safety§

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