Rename Parse::State to Parse::StateKind (#5249)

Also renames variables of that type to match. A follow-up PR will rename
`Parse::StateStackEntry` to `Parse::State`. This is more consistent with
the naming of similar enums elsewhere in the toolchain, and with the
prevailing practice of using `state` rather than e.g. `entry` as the
name of a `StateStackEntry`.

See also discussion
[here](https://discord.com/channels/655572317891461132/963846118964350976/1326280585592700990)
This commit is contained in:
Geoff Romer
2025-04-05 04:25:00 +00:00
committed by GitHub
parent 2fa2425ef5
commit 8c113c1241
36 changed files with 347 additions and 328 deletions
+7 -7
View File
@@ -436,14 +436,14 @@ auto Context::DiagnoseExpectedDeclSemiOrDefinition(Lex::TokenKind expected_kind)
// definitions are deferred, such as a class or interface.
static auto ParsingInDeferredDefinitionScope(Context& context) -> bool {
auto& stack = context.state_stack();
if (stack.size() < 2 || stack.back().state != State::DeclScopeLoop) {
if (stack.size() < 2 || stack.back().kind != StateKind::DeclScopeLoop) {
return false;
}
auto state = stack[stack.size() - 2].state;
return state == State::DeclDefinitionFinishAsClass ||
state == State::DeclDefinitionFinishAsImpl ||
state == State::DeclDefinitionFinishAsInterface ||
state == State::DeclDefinitionFinishAsNamedConstraint;
auto kind = stack[stack.size() - 2].kind;
return kind == StateKind::DeclDefinitionFinishAsClass ||
kind == StateKind::DeclDefinitionFinishAsImpl ||
kind == StateKind::DeclDefinitionFinishAsInterface ||
kind == StateKind::DeclDefinitionFinishAsNamedConstraint;
}
auto Context::AddFunctionDefinitionStart(Lex::TokenIndex token, bool has_error)
@@ -470,7 +470,7 @@ auto Context::AddFunctionDefinition(Lex::TokenIndex token, bool has_error)
auto Context::PrintForStackDump(llvm::raw_ostream& output) const -> void {
output << "Parser stack:\n";
for (auto [i, entry] : llvm::enumerate(state_stack_)) {
output << "\t" << i << ".\t" << entry.state;
output << "\t" << i << ".\t" << entry.kind;
PrintTokenForStackDump(output, entry.token);
}
output << "\tcursor\tposition_";