Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Nadrieril opened this issue May 17, 2020 · 2 comments
Open

Comments

@Nadrieril
Copy link
Contributor

Nadrieril commented May 17, 2020

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.

@Abdillah
Copy link

Abdillah commented Jul 31, 2021

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.

@Abdillah
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants