Choice parsing in toolchain (#3574)

Implement Choice parsing in toolchain according to
[design](https://github.com/carbon-language/carbon-lang/blob/trunk/docs/design/sum_types.md).
This commit is contained in:
kshokhin
2024-01-23 18:22:27 +00:00
committed by GitHub
parent afd194de9d
commit 65e95942de
16 changed files with 491 additions and 0 deletions
@@ -158,6 +158,11 @@ static auto TryHandleAsDecl(Context& context, Context::StateStackEntry state,
State::VarAsDecl);
return true;
}
case Lex::TokenKind::Choice: {
ApplyIntroducer(context, state, NodeKind::ChoiceIntroducer,
State::ChoiceIntroducer);
return true;
}
case Lex::TokenKind::Semi: {
if (saw_modifier) {
@@ -201,6 +206,7 @@ static auto ResolveAmbiguousTokenAsDeclaration(Context& context,
#define CARBON_PARSE_NODE_KIND_TOKEN_MODIFIER(Name, ...) \
case Lex::TokenKind::Name:
#include "toolchain/parse/node_kind.def"
return false;
default: