mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-15 11:28:31 +00:00
Add PushState overload to combine Parse::State change with StateStackEntry (#3485)
Shortens a common `PushState` pattern
This commit is contained in:
1 parent
6e65a30b5d
commit
b7d129b88c
17 files changed
+47
-87
No files matched your search
@@ -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);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user