-
-
Notifications
You must be signed in to change notification settings - Fork 144
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
Combinator for Eliminating Left Recursion #95
Comments
Hello! This pattern is actually even easier to achieve in chumsky with let sum = expr
.then(just('+').ignore_then(expr).repeated())
.foldl(|(lhs, rhs)| Expr::Add(lhs, rhs)); You can also define it recursively as per your original example, although in practice there's no real need to (iteratively is both faster and won't potentially result in stack overflows): let sum = recursive(|sum| {
expr.then(just('+').ignore_then(sum))
.map(|(lhs, rhs)| Expr::add(lhs, rhs))
.or(expr)
}); |
Closing this in lieu of a response, tell me if it's not solved and I can reopen it. |
Is it possible to not use And sorry if it is off-topic of this issue. |
Yes, it is possible to blow the stack by using recursive patterns in this way. On |
When writing parsers by hand and dealing with left recursion I generally use the following pattern:
As I understand this is fairly common way of eliminating left recursion (I don't have an academic background so I don't know its name) but I was unable to find a good way of using this method with the provided what would be that best way of accomplishing this?
The text was updated successfully, but these errors were encountered: