-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Clarify naming around paren expressions #3444
Clarify naming around paren expressions #3444
Conversation
(Split out of carbon-language#3410) Consistently use `ParenExpr` solely for parenthesized single expressions, and use more syntax-oriented terminology for states and nodes that might represent either a `ParenExpr` or a tuple literal.
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.
Thanks for splitting this out!
// ( ... ) | ||
// ^ |
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.
Can this occur on TupleLiteralElementFinish? Should it be removed or replaced with something like ( ... , ... )
pointing to the close )
?
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 may be right that at the moment the "..." always contains a comma, but that's not an invariant that HandleTupleLiteralElementFinish
either enforces or relies on; it's just a contingent fact about how this state is currently used. In particular, if we chose to reimplement CallExpr
in terms of TupleLiteral
, that would no longer be true, and as far as I know, nothing about TupleLiteralElementFinish
itself would need to change to accommodate that. As a result, I don't see much benefit to narrowing its contract in that way.
// On a comma, push another expression handler. | ||
if (list_token_kind == Context::ListTokenKind::Comma) { |
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 found this confusing, given that we always have a comma in this case.
// On a comma, push another expression handler. | |
if (list_token_kind == Context::ListTokenKind::Comma) { | |
// If the close paren is not next, push another expression handler. | |
if (list_token_kind != Context::ListTokenKind::CommaClose) { |
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.
Done, but with some other comment changes in light of your other comment.
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.
A couple of tiny comments, but then LGTM.
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.
Looks good, not merging due to conflicts.
(Split out of #3410)
Consistently use
ParenExpr
solely for parenthesized single expressions, and use more syntax-oriented terminology for states and nodes that might represent either aParenExpr
or a tuple literal.