-
Notifications
You must be signed in to change notification settings - Fork 441
Simplify checking if a token can be an argument label #1911
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
Sources/SwiftParser/Names.swift
Outdated
case .identifier, .wildcard: | ||
// Identifiers, escaped identifiers, and '_' can be argument labels. | ||
return true | ||
case .dollarIdentifier: | ||
return allowDollarIdentifier | ||
case .keyword(.inout): | ||
// `inout` is reserved as an argument label for historical reasons. |
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 realize this is copied from above, but wouldn't this make it not reserved, ie. inout
cannot be an argument label?
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.
Yes. Updated
@@ -235,19 +235,50 @@ extension Parser { | |||
mutating func parseSimpleType( | |||
stopAtFirstPeriod: Bool = false | |||
) -> RawTypeSyntax { | |||
enum TypeBaseStart: TokenSpecSet { |
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.
So much boilerplate :(
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.
Maybe a stupid question: is it possible to use one of the generated ones?
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 don’t think there’s any one that has these cases because we do walk into different parsing functions based on the token, similar to ExpressionModifierKeyword
.
4b4ae9c
to
0664c79
Compare
@swift-ci Please test |
Sources/SwiftParser/Types.swift
Outdated
case .wildcard: return .wildcard | ||
} | ||
} | ||
|
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.
Nitpick: newline 😬
@@ -235,19 +235,50 @@ extension Parser { | |||
mutating func parseSimpleType( | |||
stopAtFirstPeriod: Bool = false | |||
) -> RawTypeSyntax { | |||
enum TypeBaseStart: TokenSpecSet { |
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.
Maybe a stupid question: is it possible to use one of the generated ones?
0664c79
to
00845be
Compare
00845be
to
011f790
Compare
@swift-ci Please test |
@swift-ci Please test Windows |
Mostly, change
self.currentToken.canBeArgumentLabel
toself.atArgumentLabel
.Also some other miscellaneous smaller improvements in the parser.