Add PushState overload to combine Parse::State change with StateStackEntry (#3485)

Shortens a common `PushState` pattern
This commit is contained in:
josh11b
2023-12-08 23:58:30 +00:00
committed by GitHub
parent 6e65a30b5d
commit b7d129b88c
17 changed files with 47 additions and 87 deletions
+2 -4
View File
@@ -12,11 +12,10 @@ namespace Carbon::Parse {
auto HandleArrayExpr(Context& context) -> void {
auto state = context.PopState();
state.state = State::ArrayExprSemi;
context.AddLeafNode(NodeKind::ArrayExprStart,
context.ConsumeChecked(Lex::TokenKind::OpenSquareBracket),
state.has_error);
context.PushState(state);
context.PushState(state, State::ArrayExprSemi);
context.PushState(State::Expr);
}
@@ -33,8 +32,7 @@ auto HandleArrayExprSemi(Context& context) -> void {
context.AddNode(NodeKind::ArrayExprSemi, *semi, state.subtree_start,
state.has_error);
}
state.state = State::ArrayExprFinish;
context.PushState(state);
context.PushState(state, State::ArrayExprFinish);
if (!context.PositionIs(Lex::TokenKind::CloseSquareBracket)) {
context.PushState(State::Expr);
}