mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-26 08:01:14 +00:00
Unify DeclaredName and DesignatedName as just Identifier (#2939)
This is just a simplification: I think these different forms are getting in the way more than they're helping, particularly as I was looking into namespace functionality. The handling in semantics can be identical, providing a more uniform behavior.
This commit is contained in:
1 parent
2e7ce09c34
commit
5a90f660b9
188 files changed
+487
-498
No files matched your search
@@ -14,17 +14,17 @@ auto ParserHandleDesignator(ParserContext& context, bool as_struct) -> void {
|
||||
auto dot = context.ConsumeChecked(TokenKind::Period);
|
||||
|
||||
if (!context.ConsumeAndAddLeafNodeIf(TokenKind::Identifier,
|
||||
ParseNodeKind::DesignatedName)) {
|
||||
ParseNodeKind::Identifier)) {
|
||||
CARBON_DIAGNOSTIC(ExpectedIdentifierAfterDot, Error,
|
||||
"Expected identifier after `.`.");
|
||||
context.emitter().Emit(*context.position(), ExpectedIdentifierAfterDot);
|
||||
// If we see a keyword, assume it was intended to be the designated name.
|
||||
// TODO: Should keywords be valid in designators?
|
||||
if (context.PositionKind().is_keyword()) {
|
||||
context.AddLeafNode(ParseNodeKind::DesignatedName, context.Consume(),
|
||||
context.AddLeafNode(ParseNodeKind::Identifier, context.Consume(),
|
||||
/*has_error=*/true);
|
||||
} else {
|
||||
context.AddLeafNode(ParseNodeKind::DesignatedName, *context.position(),
|
||||
context.AddLeafNode(ParseNodeKind::Identifier, *context.position(),
|
||||
/*has_error=*/true);
|
||||
// Indicate the error to the parent state so that it can avoid producing
|
||||
// more errors.
|
||||
|
||||
Reference in new issue
Block a user