Parsing support for adapt declarations. (#3871)

This commit is contained in:
Richard Smith
2024-04-09 13:27:33 +00:00
committed by GitHub
parent bb117aea3a
commit c5b7ff212b
7 changed files with 261 additions and 1 deletions
@@ -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: