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:
Jon Ross-Perkins authored and GitHub committed 2023-12-08 17:29:23 +00:00
1 parent 3b0923c81d
commit 50071532fe
5 files changed
+62 -58

No files matched your search

+6 -6
View File
@@ -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.