-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Allow comments between intersection types and by-ref params #10125
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
Allow comments between intersection types and by-ref params #10125
Conversation
3671e1a
to
dc6daf2
Compare
/cc @cmb69 Also mentioning you as you expressed distaste for a regex solution. Let me know if this is fine or if you prefer to see this compared to GLP first. I agree that we should switch to GLP sooner or later. |
Impressive :) |
Let's say that I'm generally not happy with complicating the parser with work-arounds, but this is okay for me. |
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.
This is kinda cursed... but sure why not.
FWIW I also just tried switching to Bison GLR and it's very simple. Bison also allows declaring the expected number of conflicts using @bwoebi Would be interested in your opinion here. |
I can imagine @dseguy be frustrating about merging back the ampersand tokens, as I know he found it useful for Exakat. :) |
Cool! (I guess more could be simplified.)
We would need to measure, but assuming OPcache is enabled, some performance degradation in the parser shouldn't be a big deal. But given that the tokens would change, I don't think we can introduce that in a minor version. |
Yes, there are more lexer/parser hacks we could get rid of. I just wanted to see if it worked.
The |
Ah, indeed! So maybe it might be an option to switch to GLR in the next minor. Should be discussed on the ML, anyway. |
:-) So, the good thing about glr is that it allows bison to do much more lookahead and the bad thing is that you may have more lookahead.
The problem is that you now potentially run into degenerate cases (which is hard to test for, given that e.g. it might occur in big generated codes), if the grammar is not carefully constrained, especially with grammars as complex as PHPs. Even if it's not a problem today (as our grammar currently is well constrained, given it runs at all with no GLR), that's a problem for future developments because it's very hard to estimate how "well constrained" a new addition is, until you get the bug reports from users that their code which worked well up to now suddenly takes a second to compile. And that's why we haven't used GLR yet. It's a nice catch-all solution, with hidden drawbacks. Even though I'd love to see GLR because it makes things simpler from a dev perspective... I'd rather not. |
It is quite wicked syntax, indeed. |
@bwoebi Thanks for your insight. I'm fine with this approach then. For generics we can use the turbofish syntax, if it ever comes to that. I don't know of any other addition atm that would require a GLR parser. |
dc6daf2
to
8f899d2
Compare
Follow up to GH-10084. Found a way to do this after all. /cc @olleharstedt