Files
carbon-lang/toolchain/parse/handle_pattern.cpp
T
2025-03-06 19:06:51 +00:00

27 lines
846 B
C++

// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#include "toolchain/parse/context.h"
#include "toolchain/parse/handle.h"
namespace Carbon::Parse {
auto HandlePattern(Context& context) -> void {
auto state = context.PopState();
switch (context.PositionKind()) {
case Lex::TokenKind::OpenParen:
context.PushStateForPattern(State::PatternListAsTuple,
state.in_var_pattern);
break;
case Lex::TokenKind::Var:
context.PushStateForPattern(State::VariablePattern, state.in_var_pattern);
break;
default:
context.PushStateForPattern(State::BindingPattern, state.in_var_pattern);
break;
}
}
} // namespace Carbon::Parse