mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +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
@@ -179,8 +179,9 @@ auto HandleExprInPostfix(Context& context) -> void {
|
||||
// For periods, we look at the next token to form a designator like
|
||||
// `.Member` or `.Self`.
|
||||
auto period = context.Consume();
|
||||
if (context.ConsumeAndAddLeafNodeIf(Lex::TokenKind::Identifier,
|
||||
NodeKind::IdentifierName)) {
|
||||
if (context.ConsumeAndAddLeafNodeIf(
|
||||
Lex::TokenKind::Identifier,
|
||||
NodeKind::IdentifierNameNotBeforeParams)) {
|
||||
// OK, `.` identifier.
|
||||
} else if (context.ConsumeAndAddLeafNodeIf(
|
||||
Lex::TokenKind::SelfTypeIdentifier,
|
||||
@@ -193,8 +194,8 @@ auto HandleExprInPostfix(Context& context) -> void {
|
||||
ExpectedIdentifierOrSelfAfterPeriod);
|
||||
// Only consume if it is a number or word.
|
||||
if (context.PositionKind().is_keyword()) {
|
||||
context.AddLeafNode(NodeKind::IdentifierName, context.Consume(),
|
||||
/*has_error=*/true);
|
||||
context.AddLeafNode(NodeKind::IdentifierNameNotBeforeParams,
|
||||
context.Consume(), /*has_error=*/true);
|
||||
} else if (context.PositionIs(Lex::TokenKind::IntLiteral)) {
|
||||
context.AddInvalidParse(context.Consume());
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user