-
Notifications
You must be signed in to change notification settings - Fork 67
Reduce if statements for always-succeed cases #577
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
Comments
This is separate, but potentially related to #576. |
This is already should be implemented, inference-match-result pass does the job. You found an example where something else can be removed? |
Here is a cut-down example: Foo
= either " "
either
= "."
/ [a-z]* which has this in the output js: function peg$parseFoo() {
var s0, s1, s2;
s0 = peg$currPos;
s1 = peg$parseeither();
if (s1 !== peg$FAILED) {
... |
Just came to look at this again, and it took me a few seconds to realize that |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If a rule always succeeds, the code that calls that rule does not need to check the result of its parse function. The else from that check is difficult to test without resorting to tricks.
The text was updated successfully, but these errors were encountered: