Skip to content

libSyntax: add a mechanism to synthesize syntax nodes in SyntaxParsingContext. #16158

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

Merged
merged 1 commit into from
Apr 26, 2018
Merged

libSyntax: add a mechanism to synthesize syntax nodes in SyntaxParsingContext. #16158

merged 1 commit into from
Apr 26, 2018

Conversation

nkcsgexi
Copy link
Contributor

To enhance the error-recovery of syntax parsing, this patch allows the
parser to synthesize missing nodes to satisfy the requirement of a
syntax node under parsing. As proof-of-concept, we synthesize r-braces
for function body to avoid regressing a function decl to an unknown
decl.

@nkcsgexi nkcsgexi requested review from rintaro and ahoppen April 25, 2018 21:36
@nkcsgexi
Copy link
Contributor Author

@swift-ci please smoke test

@ahoppen
Copy link
Member

ahoppen commented Apr 25, 2018

LGTM

I'm just thinking we might want to disallow passing missing nodes to non-optional children in the factory methods so that users can't create invalid syntax trees.

@nkcsgexi
Copy link
Contributor Author

@ahoppen hmm, i think there's no problem to allow users to create syntax nodes with missing children. Since parser wants to do this any way to keep the tree as meaningful as it can.


// Function body without closing brace token.
func foo() {
var a = 2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add newline at the end? Test for preserving trivia for EOF is important here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do!

…gContext.

To enhance the error-recovery of syntax parsing, this patch allows the
parser to synthesize missing nodes to satisfy the requirement of a
syntax node under parsing. As proof-of-concept, we synthesize r-braces
for function body to avoid regressing a function decl to an unknown
decl.
@nkcsgexi
Copy link
Contributor Author

@swift-ci please smoke test

@nkcsgexi nkcsgexi merged commit e8c8087 into swiftlang:master Apr 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants