mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 07:11:04 +01:00
Track params in the parser (#4777)
This change splits `NodeKind::IdentifierName` into separate node kinds depending on whether the identifier is followed by parameters, and similarly splits `NameQualifier` based on whether the qualifier has parameters. This enables us to only push a pattern block when it's actually needed, rather than "defensively" pushing one when it might be needed. --------- Co-authored-by: Jon Ross-Perkins <jperkins@google.com>
This commit is contained in:
co-authored by
Jon Ross-Perkins
parent
8f685b6953
commit
4f10735751
@@ -40,7 +40,7 @@ auto HandleBindingPattern(Context& context) -> void {
|
||||
// The first item should be an identifier or `self`.
|
||||
bool has_name = false;
|
||||
if (auto identifier = context.ConsumeIf(Lex::TokenKind::Identifier)) {
|
||||
context.AddLeafNode(NodeKind::IdentifierName, *identifier);
|
||||
context.AddLeafNode(NodeKind::IdentifierNameNotBeforeParams, *identifier);
|
||||
has_name = true;
|
||||
} else if (auto self =
|
||||
context.ConsumeIf(Lex::TokenKind::SelfValueIdentifier)) {
|
||||
@@ -51,8 +51,8 @@ auto HandleBindingPattern(Context& context) -> void {
|
||||
}
|
||||
if (!has_name) {
|
||||
// Add a placeholder for the name.
|
||||
context.AddLeafNode(NodeKind::IdentifierName, *context.position(),
|
||||
/*has_error=*/true);
|
||||
context.AddLeafNode(NodeKind::IdentifierNameNotBeforeParams,
|
||||
*context.position(), /*has_error=*/true);
|
||||
on_error(/*expected_name=*/true);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user