-
-
Notifications
You must be signed in to change notification settings - Fork 414
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
Added interegular support #1258
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very cool! I'll clear some time soon to test it.
It would be nice to have an automated test for the basic use of this feature..
So many checks, many of which are hard to execute locally tbh:
Oh, and the codecov workflow always fails with "nothing to run". Do you have an idea what is going on there? |
Sorry, I didn't look into the codecov yet. I'm okay with just disabling it in the meantime. As for tox, makes sense that mypy would pass but regular tests won't. Mypy doesn't run the tests. |
The code looks good, but I'm not crazy about the warning message -
I'm sure we can do better.
|
Uhm... This is then a bug in interegular. OTOH, I could have sworn the eample for
Fair, although I worry that a grammar would many collision would product a lot of warning text.
I am unsure how to best format this. What |
Ok, I am now relatively happy with the warning message. It's decently complex code, but the result is IMO very readable. The formatting should now also never break, not even for newlines or weird unicode characters. Especially newlines is the reason I was using repr before. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
You want to add the docs in a separate PR, or add them here?
I can add them here. Where would you want them? |
Hmm yeah there's no obvious spot. I'd say -
I'm open to ideas. Anyway, once that's in, I wanted to add a |
how_to_use#debug I assume |
Btw, the default config |
I think so.
Well, colliding regexes are still slower, because Earley has to try all variations. But it won't cause an error. So maybe a milder warning in that case? (assuming it doesn't complicate things too much) |
I would have to look through the earley code base to find a good place to put this check. They don't construct a Lexer object after all, and especially not a |
Umm actually that's only true for dynamic_complete. The default dynamic can still get errors from colliding regexes. (if it chooses the wrong one first) (I'm talking about my comment) |
I rephrased the docs a little bit, let me know if you're okay with the changes: #1260 Also, I just realized we're only showing shift/reduce warnings when debug=True. Maybe we should use the same convention for interegular? |
Yeah, those changes are good. I am not that skilled with words :-)
I was thinking about this as well. I decided against it, since regex collisions are from my understanding more severe than shift/reduce collisions. I.e. for shift/reduce the automatic resolving probably will do the correct thing, for regex collision, the automatic resolving will maybe do the correct thing. |
I think I agree. But I was also thinking about the possibility of interegular throwing exceptions, which might interfere with normal use. For example certain regex features it doesn't know about, or perhaps some edge case it wasn't expecting. If that's a possibility, then it would be nice to have a way to disable/enable it, that isn't installing/uninstalling it. |
interegular should catch every exception it can throw and only produce a warning on it's internal logger. We probably should make the |
That's not a bad idea. Makes sense that it would set the appropriate logger levels to DEBUG by default. |
Can you please show me where this exception gets caught? https://github.com/MegaIng/interegular/blob/master/interegular/fsm.py#L431 Maybe I'm missing something obvious. |
It's used internally inside of |
Ah, yes. Missed that it's a callback. |
Rephrased docs for interegular PR (#1258)
Thanks for the awesome new feature! |
I also published a new version of interegular that should double the performance again. :-D |
This is basically the same as #715 , with (I think) all requested changes being considered. I also added an Example to the log output that can show in what situation two terminals would collide.
I created a new PR after having a mess after a git rebase. This just seemed easier.
I guess it should be mentioned somewhere in the docs, not sure where.