Support declaration modifier keywords (#3412)

Co-authored-by: Jon Ross-Perkins <jperkins@google.com>
This commit is contained in:
josh11b
2023-12-05 22:45:57 +00:00
committed by GitHub
co-authored by Jon Ross-Perkins
parent 22dff46ed2
commit fada410559
54 changed files with 1779 additions and 244 deletions
+3
View File
@@ -32,6 +32,7 @@ auto HandleStatement(Context& context) -> void {
}
case Lex::TokenKind::Let: {
context.PushState(State::Let);
context.AddLeafNode(NodeKind::LetIntroducer, context.Consume());
break;
}
case Lex::TokenKind::Return: {
@@ -44,6 +45,7 @@ auto HandleStatement(Context& context) -> void {
}
case Lex::TokenKind::Var: {
context.PushState(State::VarAsDecl);
context.AddLeafNode(NodeKind::VariableIntroducer, context.Consume());
break;
}
case Lex::TokenKind::While: {
@@ -101,6 +103,7 @@ auto HandleStatementForHeader(Context& context) -> void {
if (context.PositionIs(Lex::TokenKind::Var)) {
context.PushState(state);
context.PushState(State::VarAsFor);
context.AddLeafNode(NodeKind::VariableIntroducer, context.Consume());
} else {
CARBON_DIAGNOSTIC(ExpectedVariableDecl, Error,
"Expected `var` declaration.");