mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-04 17:51:05 +01:00
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:
@@ -14,7 +14,7 @@ auto HandleBindingPattern(Context& context) -> void {
|
||||
// An `addr` pattern may wrap the binding, and becomes the parent of the
|
||||
// `BindingPattern`.
|
||||
if (auto token = context.ConsumeIf(Lex::TokenKind::Addr)) {
|
||||
context.PushState({.state = State::BindingPatternAddr,
|
||||
context.PushState({.kind = StateKind::BindingPatternAddr,
|
||||
.in_var_pattern = state.in_var_pattern,
|
||||
.token = *token,
|
||||
.subtree_start = state.subtree_start});
|
||||
@@ -56,11 +56,12 @@ auto HandleBindingPattern(Context& context) -> void {
|
||||
*context.position(), /*has_error=*/true);
|
||||
on_error(/*expected_name=*/true);
|
||||
}
|
||||
if (auto kind = context.PositionKind();
|
||||
kind == Lex::TokenKind::Colon || kind == Lex::TokenKind::ColonExclaim) {
|
||||
if (auto token_kind = context.PositionKind();
|
||||
token_kind == Lex::TokenKind::Colon ||
|
||||
token_kind == Lex::TokenKind::ColonExclaim) {
|
||||
// Add the wrapper node for the `template` keyword if present.
|
||||
if (template_token) {
|
||||
if (kind != Lex::TokenKind::ColonExclaim && !state.has_error) {
|
||||
if (token_kind != Lex::TokenKind::ColonExclaim && !state.has_error) {
|
||||
CARBON_DIAGNOSTIC(ExpectedGenericBindingPatternAfterTemplate, Error,
|
||||
"expected `:!` binding after `template`");
|
||||
context.emitter().Emit(*template_token,
|
||||
@@ -71,9 +72,9 @@ auto HandleBindingPattern(Context& context) -> void {
|
||||
state.has_error);
|
||||
}
|
||||
|
||||
state.state = kind == Lex::TokenKind::Colon
|
||||
? State::BindingPatternFinishAsRegular
|
||||
: State::BindingPatternFinishAsGeneric;
|
||||
state.kind = token_kind == Lex::TokenKind::Colon
|
||||
? StateKind::BindingPatternFinishAsRegular
|
||||
: StateKind::BindingPatternFinishAsGeneric;
|
||||
// Use the `:` or `:!` for the root node.
|
||||
state.token = context.Consume();
|
||||
context.PushState(state);
|
||||
@@ -82,7 +83,7 @@ auto HandleBindingPattern(Context& context) -> void {
|
||||
on_error(/*expected_name=*/false);
|
||||
// Add a substitute for a type node.
|
||||
context.AddInvalidParse(*context.position());
|
||||
context.PushState(state, State::BindingPatternFinishAsRegular);
|
||||
context.PushState(state, StateKind::BindingPatternFinishAsRegular);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user