mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 08:31:04 +01:00
Separate node kind for bindings inside var (#4822)
This is a step toward making binding pattern handling more robust, by removing its reliance on the node stack for context.
This commit is contained in:
@@ -10,10 +10,10 @@ namespace Carbon::Parse {
|
||||
// Handles PatternListElementAs(Implicit|Tuple).
|
||||
static auto HandlePatternListElement(Context& context, State pattern_state,
|
||||
State finish_state) -> void {
|
||||
context.PopAndDiscardState();
|
||||
auto state = context.PopState();
|
||||
|
||||
context.PushState(finish_state);
|
||||
context.PushState(pattern_state);
|
||||
context.PushStateForPattern(finish_state, state.in_var_pattern);
|
||||
context.PushStateForPattern(pattern_state, state.in_var_pattern);
|
||||
}
|
||||
|
||||
auto HandlePatternListElementAsImplicit(Context& context) -> void {
|
||||
@@ -39,7 +39,7 @@ static auto HandlePatternListElementFinish(Context& context,
|
||||
if (context.ConsumeListToken(NodeKind::PatternListComma, close_token,
|
||||
state.has_error) ==
|
||||
Context::ListTokenKind::Comma) {
|
||||
context.PushState(param_state);
|
||||
context.PushStateForPattern(param_state, state.in_var_pattern);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,13 +58,13 @@ static auto HandlePatternList(Context& context, NodeKind node_kind,
|
||||
Lex::TokenKind open_token_kind,
|
||||
Lex::TokenKind close_token_kind,
|
||||
State param_state, State finish_state) -> void {
|
||||
context.PopAndDiscardState();
|
||||
auto state = context.PopState();
|
||||
|
||||
context.PushState(finish_state);
|
||||
context.PushStateForPattern(finish_state, state.in_var_pattern);
|
||||
context.AddLeafNode(node_kind, context.ConsumeChecked(open_token_kind));
|
||||
|
||||
if (!context.PositionIs(close_token_kind)) {
|
||||
context.PushState(param_state);
|
||||
context.PushStateForPattern(param_state, state.in_var_pattern);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user