-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Formalize Labeled Syntax #60396
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
Formalize Labeled Syntax #60396
Conversation
@swift-ci please smoke test |
@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.
Sounds like an improvement to me 👍
@swift-ci please smoke test |
@swift-ci please smoke test macOS |
1 similar comment
@swift-ci please smoke test macOS |
This represents labeled statements as an explicit kind of statement and removes the Labeled trait. Any kind of statement is allowed to be labeled in the tree, but we specifically diagnose the syntax elements that aren't allowed to have labels. This homogenizes the way clients deal with statement labels and also makes parser recovery quite a bit easier in the case where we have a label but no actual statement following it.
@swift-ci please smoke test macOS |
@swift-ci please smoke test |
# while-stmt -> label? ':'? 'while' condition-list code-block ';'? | ||
Node('WhileStmt', kind='Stmt', | ||
traits=['WithCodeBlock', 'Labeled'], | ||
traits=['WithCodeBlock'], |
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.
Should the specifications be updated as well?
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.
What specification are you referring to? The "grammar" is still correct - we don't necessarily want the notion of a "labeled statement" in the formal grammar since not all the statements support labels!
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 was referring to the comment in the above preview (ditto the other nodes you modified), not the actual grammar in the language reference, although, curiously, it does have a notion of a labeled statement too.
This represents labeled statements as an explicit kind of statement and removes the Labeled trait. Any kind of statement is allowed to be labeled in the tree, but we specifically diagnose the syntax elements that aren't allowed to have labels. This homogenizes the way clients deal with statement labels and also makes parser recovery quite a bit easier in the case where we have a label but no actual statement following it.