-
Notifications
You must be signed in to change notification settings - Fork 22
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
Incorrect regex translation #32
Comments
@agentzh I don't see this as a bug. Pegex cannot know when to add parens in a regex.
or:
Would be the proper way to do it. https://github.com/ingydotnet/pegex-pgx/blob/master/pegex.pgx#L53 is the regex parsing rule. It just splits up stuff between 2 Maybe a doc patch is in order somewhere? |
@ingydotnet I can understand the implementation complications here but mandating a |
The problem here is scope of concern. I'd have to special case that. And how does that compare to
To pegex the Also these 2 are equal:
Now what could work is this:
The pipe is Pegex syntax here. It's between 2 regexes that can be optimized into:
The optimizer would know that it must add parens. Maybe we can add degugging that shows the regex or something. I'm happy to make Pegex more user friendly, but (unless I don't understand what you are wanting) I see this as leading to a world of special cases. |
@ingydotnet Yeah, it requires more work on the regex translator to get exactly right. I'll try living with it for now :) Not a big deal for me. |
The optimizer should be made to handle this correctly (I now believe). |
@ingydotnet Yay! |
Hi Ingy!
I ran into a bug in the Pegex grammar translator that took me a while to figure out. Basically the following Pegex regex
is translated into the following Perl regex:
while the expected Perl regex should be
Adding
(: ...)
to the original Pegex regex worked around this bug.The text was updated successfully, but these errors were encountered: