Skip to content

[Parse] refactor get/set block parsing #19046

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 2 commits into from
Aug 31, 2018

Conversation

rintaro
Copy link
Member

@rintaro rintaro commented Aug 29, 2018

Use parseAbstractFunctionBody()(introduced in #19018) to parse accessor body as well. This simplifies the implementation, and makes parseAbstractFunctionBody() the single point of parsing body of every AbstractFunctionDecl types.

Also, since parseAbstractFunctionBody() automatically handles delayed parsing by delayFunctionBodyParsing(), we no longer use delayed parsing facilities specific for accessor bodies.

* Use 'parseAbstractFunctionBody()' for accessors as well. This
  simplifies the implementation, and makes 'parseAbstractFunctionBody()'
  the single point of parsing body of every 'AbstructFunctionDecl' types.
Now that, parsing accessor body is done by 'parseAbstractFunctionBody()'
which automatically handles delayed parsing by `delayFunctionBodyParsing()`.
So we no longer use delayed parsing facilities specific for accessor body.
Child('Accessor', kind='Syntax', is_optional=True,
node_choices=[
Child('Accessors', kind='AccessorBlock'),
Child('Getter', kind='CodeBlock')]),
Copy link
Member Author

@rintaro rintaro Aug 29, 2018

Choose a reason for hiding this comment

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

This change aligns with the language reference:
https://docs.swift.org/swift-book/ReferenceManual/Declarations.html#//appleref/swift/grammar/variable-declaration

variable-declaration → variable-declaration-head variable-name type-annotation code-block
variable-declaration → variable-declaration-head variable-name type-annotation getter-setter-block

CC: @nkcsgexi

@rintaro
Copy link
Member Author

rintaro commented Aug 29, 2018

@swift-ci Please smoke test

@rintaro
Copy link
Member Author

rintaro commented Aug 30, 2018

@akyrtzi I'm not sure you are the right person to ask, but are you OK with removing delayAccessorBodyParsing() related facilities?

@akyrtzi
Copy link
Contributor

akyrtzi commented Aug 30, 2018

I'm not super familiar with it but it seems like a nice cleanup to me.

@rintaro rintaro merged commit 2a1ab7d into swiftlang:master Aug 31, 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.

2 participants