Skip to content

Solve left-recursion and improve error recovery using pika parsing #460

Open

Description

@Nadrieril

This recent paper (https://arxiv.org/abs/2005.06444) describes an alternative technique for parsing PEG grammars: instead of top-down, left-to-right, they propose a bottom-up, right-to-left approach, that correctly handles left-recursion and apparently has also better errors.
It's essentially packrat parsing but with a different approach to dynamic programming, so the semantics are identical.
I know the pest team doesn't currently have a lot of resources but I thought this was a cool idea if someone else is interested. I think it would be possible to make a generic external parsing library that pest can then use instead of its own packrat parser.

Activity

  1. Abdillah commented on Jul 31, 2021

    @Abdillah

    How about this one (https://www.sciencedirect.com/science/article/pii/S0167642314000288)?
    I think this one more suitable for top-down by specially handling a recursive pattern.

    It uses a memoization just like the packrat parser to store the matching of minimum recursive bound (zero recurse). Then the algorithm incrementally increases the bound to make it greedy enough while still utilizing the stored value to make it faster. When it fails it stops.

    The Pest PEG can be augmented with a recursive marker to tell an intentional recursive pattern. Then everything can start from there, while unmarked one still produces error.

  2. Abdillah commented on Aug 21, 2021

    @Abdillah

    I'm trying to implement the paper (or as close as I understand), here #533.

  3. added this to the v3.0 milestone on Nov 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions