-
Notifications
You must be signed in to change notification settings - Fork 440
Add API to enable or disable bare slash regex parsing #448
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
Conversation
@swift-ci Please test |
languageVersion: String? = nil, | ||
enableBareSlashRegexLiteral: Bool? = nil, |
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.
I feel like these should be a Options
object. But I'm not sure how the API should look like, for example
// An array of enums
SyntaxParse.parse(
url,
options: [.languageVersion("5.6"), .bareSlashRegexLiteral(true)],
diagnosticHandler: diagnosticHandler)
// Just a "options" object
SyntaxParse.parse(
url,
options: SyntaxParseOptions(languageVersion: "5.1", enableBareSlashRegexLiteral: true),
diagnosticHandler: diagnosticHandler)
The advantage of options object is that you can easily pass around and store the object in the clients, when they want to create options at not exact the call site.
WDYT?
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.
Though it's still only in the pitch phase, it seems like a long-term API for this should build on the ideas from @DougGregor 's future feature strings.
The value passed into SyntaxParser.parse
could just be an array of strings denoting the feature names. While that's not as discoverable as strongly-typed arguments, if Swift Package Manager is already planning to use that approach (for the reasons described in that pitch), then the string array would at least be familiar and consistent for users. And it eliminates some potential instability from API users, since SwiftSyntax doesn't need to be updated every time new features are added.
This would also have the advantage of letting SwiftSyntax clients, like swift-format, provide the same -enable-future-feature
flag and pass those strings verbatim to SwiftSyntax, instead of each client having to either provide their own flags for each of these features or do their own mapping.
With all that being said, I don't know what the best design for this API should look like now if you want to land it before the future-feature work while still keeping that as the eventual end state.
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.
Alex and I chatted about this and we decided to accept this as is for now until the "language features" proposal is settled.
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.
Just resolve the conflict :)
Add a parameter to the `SyntaxParser.parse` functions to enable or disable bare slash regex parsing. rdar://93750821
e45cdc5
to
d538760
Compare
@swift-ci Please test |
Depends on swiftlang/swift#59018
Add a parameter to the
SyntaxParser.parse
functions to enable or disable bare slash regex parsing.rdar://93750821