Replies: 1 comment
-
The following might help: https://en.wikipedia.org/wiki/Left_recursion#Removing_left_recursion Here's an example of basic left-recursion removal in Pest:
Here's another example for a more complex grammar, using this algorithm.
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello. One feature that I just tried to add to a language I'm working on is function / method chaining, e.g.
From my understanding, this requires left-recursion in the grammar because
something.call1()
must be parsed and become the receiver ofcall2()
. And also from my understanding, and confirmed by an error I receive when trying to add a rule for this scenario, this isn't something thatpest
can handle.I've read that left-recursion is something that PEG itself can't handle. Somewhat confusingly, there's a series of posts about how Python uses PEG for its grammar, and how they are able to get left-recursion to work with it, but it seems like they have their own custom PEG parser-generator implementation.
So, first, is it true that left-recursion just isn't possible with
pest
? And if not, is there some other way of achieving the method chaining syntax above?Beta Was this translation helpful? Give feedback.
All reactions