Parsing support for adapt declarations. (#3871)

This commit is contained in:
Richard Smith authored and GitHub committed 2024-04-09 13:27:33 +00:00
1 parent bb117aea3a
commit c5b7ff212b
7 files changed
+261 -1

No files matched your search

@@ -110,6 +110,12 @@ static auto HandleBaseAsDecl(Context& context, Context::StateStackEntry state)
static auto TryHandleAsDecl(Context& context, Context::StateStackEntry state,
bool saw_modifier) -> bool {
switch (context.PositionKind()) {
case Lex::TokenKind::Adapt: {
ApplyIntroducer(context, state, NodeKind::AdaptIntroducer,
State::AdaptDecl);
context.PushState(State::Expr);
return true;
}
case Lex::TokenKind::Alias: {
ApplyIntroducer(context, state, NodeKind::AliasIntroducer, State::Alias);
return true;
@@ -199,6 +205,7 @@ static auto ResolveAmbiguousTokenAsDeclaration(Context& context,
// also modifiers (such as `base`). Other introducer tokens need to be
// added by hand.
switch (context.PositionKind(Lookahead::NextToken)) {
case Lex::TokenKind::Adapt:
case Lex::TokenKind::Alias:
case Lex::TokenKind::Class:
case Lex::TokenKind::Constraint: