mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-04 22:02:52 +01:00
Add PushState overload to combine Parse::State change with StateStackEntry (#3485)
Shortens a common `PushState` pattern
This commit is contained in:
@@ -8,8 +8,7 @@ namespace Carbon::Parse {
|
||||
|
||||
auto HandleFunctionIntroducer(Context& context) -> void {
|
||||
auto state = context.PopState();
|
||||
state.state = State::FunctionAfterParams;
|
||||
context.PushState(state);
|
||||
context.PushState(state, State::FunctionAfterParams);
|
||||
context.PushState(State::DeclNameAndParamsAsRequired, state.token);
|
||||
}
|
||||
|
||||
@@ -17,8 +16,7 @@ auto HandleFunctionAfterParams(Context& context) -> void {
|
||||
auto state = context.PopState();
|
||||
|
||||
// Regardless of whether there's a return type, we'll finish the signature.
|
||||
state.state = State::FunctionSignatureFinish;
|
||||
context.PushState(state);
|
||||
context.PushState(state, State::FunctionSignatureFinish);
|
||||
|
||||
// If there is a return type, parse the expression before adding the return
|
||||
// type node.
|
||||
@@ -50,8 +48,7 @@ auto HandleFunctionSignatureFinish(Context& context) -> void {
|
||||
state.subtree_start, state.has_error);
|
||||
// Any error is recorded on the FunctionDefinitionStart.
|
||||
state.has_error = false;
|
||||
state.state = State::FunctionDefinitionFinish;
|
||||
context.PushState(state);
|
||||
context.PushState(state, State::FunctionDefinitionFinish);
|
||||
context.PushState(State::StatementScopeLoop);
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user