mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 21:10:12 +01:00
`match_first` is a declaration followed by a curly-brace block of declarations. The check phase will ensure only impl decls (or defns) are inside the block.
25 lines
886 B
C++
25 lines
886 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 HandleMatchFirst(Context& context) -> void {
|
|
auto state = context.PopState();
|
|
// MatchFirstIntroducer node is automatically added for the MatchFirst state.
|
|
context.AddNode(NodeKind::MatchFirstDefinitionStart, context.Consume(),
|
|
state.has_error);
|
|
context.PushState(state, StateKind::MatchFirstFinish);
|
|
context.PushState(StateKind::DeclScopeLoopAsRegular);
|
|
}
|
|
|
|
auto HandleMatchFirstFinish(Context& context) -> void {
|
|
auto state = context.PopState();
|
|
context.AddNode(NodeKind::MatchFirst, context.Consume(), state.has_error);
|
|
}
|
|
|
|
} // namespace Carbon::Parse
|