mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-02 10:35:53 +01:00
Refactor state construction and change how the decl loop makes state. (#3467)
Building on #3463. The PushState+PopState to construct a state feels worth cleanup. The rest is just kind of making it easier to do without adding another PushState overload.
This commit is contained in:
@@ -12,15 +12,15 @@ auto HandleBindingPattern(Context& context) -> void {
|
||||
// Parameters may have keywords prefixing the pattern. They become the parent
|
||||
// for the full BindingPattern.
|
||||
if (auto token = context.ConsumeIf(Lex::TokenKind::Template)) {
|
||||
context.PushState(Context::StateStackEntry(
|
||||
State::BindingPatternTemplate, PrecedenceGroup::ForTopLevelExpr(),
|
||||
PrecedenceGroup::ForTopLevelExpr(), *token, state.subtree_start));
|
||||
context.PushState({.state = State::BindingPatternTemplate,
|
||||
.token = *token,
|
||||
.subtree_start = state.subtree_start});
|
||||
}
|
||||
|
||||
if (auto token = context.ConsumeIf(Lex::TokenKind::Addr)) {
|
||||
context.PushState(Context::StateStackEntry(
|
||||
State::BindingPatternAddress, PrecedenceGroup::ForTopLevelExpr(),
|
||||
PrecedenceGroup::ForTopLevelExpr(), *token, state.subtree_start));
|
||||
context.PushState({.state = State::BindingPatternAddress,
|
||||
.token = *token,
|
||||
.subtree_start = state.subtree_start});
|
||||
}
|
||||
|
||||
// Handle an invalid pattern introducer for parameters and variables.
|
||||
|
||||
Reference in New Issue
Block a user