mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-30 07:15:00 +01:00
Require extend before base: BaseType; (#3459)
This commit is contained in:
@@ -41,6 +41,7 @@ static auto TokenIsModifierOrIntroducer(Lex::TokenKind token_kind) -> bool {
|
||||
case Lex::TokenKind::Class:
|
||||
case Lex::TokenKind::Constraint:
|
||||
case Lex::TokenKind::Default:
|
||||
case Lex::TokenKind::Extend:
|
||||
case Lex::TokenKind::Final:
|
||||
case Lex::TokenKind::Fn:
|
||||
case Lex::TokenKind::Impl:
|
||||
@@ -188,6 +189,21 @@ auto HandleDeclScopeLoop(Context& context) -> void {
|
||||
break;
|
||||
}
|
||||
|
||||
case Lex::TokenKind::Extend: {
|
||||
// `extend` is considered a declaration modifier if it is followed by
|
||||
// another modifier or an introducer.
|
||||
if (TokenIsModifierOrIntroducer(
|
||||
context.PositionKind(Lookahead::NextToken))) {
|
||||
context.AddLeafNode(NodeKind::DeclModifierKeyword, context.Consume());
|
||||
saw_modifier = true;
|
||||
} else {
|
||||
// TODO: Treat this `extend` token as a declaration introducer
|
||||
HandleUnrecognizedDecl(context, state.subtree_start);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// If we see a declaration introducer keyword token, replace the
|
||||
// placeholder node and switch to a state to parse the rest of the
|
||||
// declaration. We don't allow namespace or empty declarations here since
|
||||
|
||||
Reference in New Issue
Block a user