-
Notifications
You must be signed in to change notification settings - Fork 51
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
A | B != B | A #188
Comments
While it is true that | is not commutative (a.backtrack | b.backtrack would be), having an infix operator is very nice. Do you have any other suggestions? |
maybe I just write graphql schema parser.
|
PEGs use |
Sorry I'm slow to reply on the weekend. You definitely don't always need backtrack with ?. I'll rewrite some of your examples without backtrack and it might give you a feel for how to do it. A big design property of this library is to encourage you to write parsers avoiding backtracking since that can easily result in accidental exponential complexity and also it generally results in poor descriptions of what went wrong. That said, we could probably do with better educational materials to help people get started. |
Also note | does act like oneOf. It is a synonym. oneOf is also not commutative, it matches left to right. |
@johnynek thanks. And I'm sorry that I misunderstand the usage of |
intuitively, i'd expect |
related to #184 |
While I'd like to take it a bit slow. |
Hey @timzaak you have quite a bit of nice parsing code. One thing you don't seem to be using is "soft products", A normal product So, for instance:
we can write instead as:
So, now, we are very precise in the backtracking: only over the whitespace part. We are not erasing an arresting error as we did above: see Does this help @timzaak ? |
@johnynek thanks, I will rewrite my code. It's a very useful advice. |
@johnynek thanks again, I rewrite the code, and it looks good to me now. |
maybe, remove this
|
method. just useorElse
The text was updated successfully, but these errors were encountered: