Skip to content

Feature request: pipelined parsers #399

@Banyc

Description

@Banyc

Say we have the two parsers:

  • fn lexer() -> impl Parser<char, Vec<Token>, Error = Simple<char>>;
  • fn token_parser() -> impl Parser<Token, Expr, Error = Simple<Token>>;

Feature request

A way to merge the two parsers as one.

let parser = token_parser().inputed_from(lexer());
parser.parse(src)

Potential benefits

  • Prevent the creation of Vec<Token> which takes up a bit of heap memory, so that it makes inter-procedures zero-copy.
  • parser.parse(src) seems cooler than let tokens = lexer.parse(src); token_parser.parse(tokens) in user code. By "users" I mean those who use the built parser(s).

My questions

  1. Is it possible to do this with current implementations?
  2. Is the idea makes sense to most use cases so that it worths being implemented?

Metadata

Metadata

Assignees

No one assigned

    Labels

    apiA problem with the design of an API featureenhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions