-
Notifications
You must be signed in to change notification settings - Fork 37
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
Custom operators are obtuse and restrictive #5
Comments
The biggest impact I'm aware of here is that the |
We still need to move the custom operator logic to the scanner, but that's a lot of complexity, and it's still unclear how to do that without a lot of breakage. Instead of doing that now, we just special case handling of `<` (which is what was tripping up a lot of Carthage files). With this change, #5 will no longer be a top-repos-error, even though it will still be a valid bug.
So it should follow the "Grammar of operators" from https://docs.swift.org/swift-book/ReferenceManual/zzSummaryOfTheGrammar.html? If so, from what I see, regexes will suffice |
It should end up more or less equivalent to that, but there’s some special casing required for cases like the ones in #41, where an operator ending in a |
Unfinished PR at #151 |
For posterity: the top-repo error here currently is at
|
Custom operator rules are better expressed as conditions to track in `eat_operator` vs a series of impenetrable regexes. Also requires a fix for an undiscovered bug where `x[...]!` was not considered to be a legal target for an expression. Since the old logic allowed `+=` to be a "custom operator", we were covering up for that failure by interpreting `x[...]! += y` as a custom infix expression. Fixes #5
Custom operator rules are better expressed as conditions to track in `eat_operator` vs a series of impenetrable regexes. Also requires a fix for an undiscovered bug where `x[...]!` was not considered to be a legal target for an expression. Since the old logic allowed `+=` to be a "custom operator", we were covering up for that failure by interpreting `x[...]! += y` as a custom infix expression. Fixes #5
Currently, a custom operator must match one of five weird regexes that have subtle differences and are each of dubious necessity. There are many legitimate character combinations that should be legal, but are not, including anything using advanced unicode (related: unicode identifiers bug).
What this really points to is that custom operators should just be defined as
externals
, where we can define the rules inscanner.c
and make it look something like what the official grammar says it should be.The text was updated successfully, but these errors were encountered: