tree-sitter-swift
tree-sitter-swift copied to clipboard
Custom operators are obtuse and restrictive
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 in scanner.c and make it look something like what the official grammar says it should be.
The biggest impact I'm aware of here is that the <*> operator from Commandant isn't legal, which causes a bunch of failures in Carthage.
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 < symbol conflicts with the start of a generic type argument.
Unfinished PR at https://github.com/alex-pinkus/tree-sitter-swift/pull/151
For posterity: the top-repo error here currently is at firefox-ios/shared/Functions.swift caused by:
infix operator •