-
Notifications
You must be signed in to change notification settings - Fork 439
Fix multiple cases where the parser produced token kinds that didn’t match the token kinds in the syntax node definitions #1436
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
7596ccb
to
f028ced
Compare
@swift-ci Please test |
Sources/SwiftParser/Types.swift
Outdated
let (name, _) = self.parseDeclNameRef(flags) | ||
mutating func parseTypeNameWithGenerics(allowKeywordAsName: Bool) -> (RawTokenSyntax, RawGenericArgumentClauseSyntax?) { | ||
let name: RawTokenSyntax | ||
if let identOrSelf = self.consume(if: .identifier, .keyword(.Self), .keyword(.Self)) { |
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.
Self
twice
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.
Oh, one of them should’ve been lowercase self
.
@@ -551,7 +551,7 @@ public let EXPR_NODES: [Node] = [ | |||
children: [ | |||
Child( | |||
name: "Identifier", | |||
kind: .token(choices: [.token(tokenKind: "IdentifierToken")]) | |||
kind: .token(choices: [.token(tokenKind: "IdentifierToken"), .keyword(text: "self"), .keyword(text: "Self"), .keyword(text: "init")]) |
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.
Editor placeholder is always <##> so ... seems weird we'd need this.
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.
You’re right, we don’t actually need it here.
f028ced
to
fa14be6
Compare
@swift-ci Please test |
@swift-ci Please test Windows |
…match the token kinds in the syntax node definitions The main problem here was that we were accepting `self` and `Self` in `expectIdentifier` but not handling that in the syntax tree. I went through every call of `expectIdentifier` and checked what the C++ parser does to maintain the behavior. Where we need to accept `self` or `Self` for compatibility reasons, it is now remapped to an identifier.
fa14be6
to
aea4442
Compare
@swift-ci Please test |
@swift-ci Please test Windows |
…matches Fix multiple cases where the parser produced token kinds that didn’t match the token kinds in the syntax node definitions
The main problem here was that we were accepting
self
andSelf
inexpectIdentifier
but not handling that in the syntax tree. I went through every call ofexpectIdentifier
and checked what the C++ parser does to maintain the behavior. Where we need to acceptself
orSelf
for compatibility reasons, it is now remapped to an identifier.In other cases, the syntax node definitions just needed to be updated.
These problems were found by the verification added in #1339.