-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[ASTGen] Utilize base specific SyntaxEnum and start Pattern generation #69829
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 smoke test |
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.
Nice!
@@ -373,7 +261,7 @@ extension ASTGenVisitor { | |||
return nil | |||
} | |||
|
|||
return self.generate(node) | |||
return self.generate(type: node) |
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.
If we're going to give these argument labels, should the optional variants also get them? Or is the intention to avoid the risk of recursion?
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, I will add argument labels to all the existing generate(_:)
functions in follow-ups.
|
||
default: | ||
fatalError("case does not correspond to an ASTNode") | ||
// CodeBlockItem -> BraceStmt or IfStmt. |
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.
Did you mean
// CodeBlockItem -> BraceStmt or IfStmt. | |
// CodeBlockSyntax -> BraceStmt or IfStmt. |
Also, if this can become an IfStmt
, can it also become a SwitchStmt
?
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.
IfStmt
was wrong. just CodeBlockSyntax
-> BraceStmt
return .expr(self.generate(expr: expr)) | ||
} | ||
if let type = node.as(TypeSyntax.self) { | ||
return .type(self.generate(type: type)) | ||
} |
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.
Don’t we need to also check for PatternSyntax
here?
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.
BridgedPattern
is not an ASTNode
at this point
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, I see. 👍🏽
test/ASTGen/types.swift
Outdated
@@ -2,7 +2,8 @@ | |||
|
|||
// -enable-experimental-feature requires an asserts build | |||
// REQUIRES: asserts | |||
// REQUIRES: rdar116686158 | |||
// rdar//116686158 |
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.
Nit
// rdar//116686158 | |
// rdar://116686158 |
test/ASTGen/verify-parse.swift
Outdated
@@ -10,7 +10,8 @@ | |||
|
|||
// -enable-experimental-feature requires an asserts build | |||
// REQUIRES: asserts | |||
// REQUIRES: rdar116686158 | |||
// rdar//116686158 |
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.
Nit
// rdar//116686158 | |
// rdar://116686158 |
2eb5116
to
215abe6
Compare
@swift-ci Please smoke test |
{Decl|Stmt|Expr|Type|Pattern}SyntaxEnum
introduced in Add SyntaxEnum per base syntax kind swift-syntax#2351generate(_: Syntax)
intogenerate(decl: DeclSyntax)
,generate(expr: ExprSyntax)
etc.Patterns.swift
to generate Patterns as the same scheme as other kinds. (C++ parser ping-pong is not implmented)