mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 22:02:23 +01:00
Change syntax for package declaration to put the `impl` keyword at the start and remove the `api` keyword. To support this, rearrange processing of package, library, and import declarations to use the general modifier handling support in declaration parsing rather than special-case logic. There is an ambiguity in `impl package.Foo as Bar`, which we resolve by treating `package` as an introducer after a modifier only if it's not followed by `.`.
30 lines
1.0 KiB
C++
30 lines
1.0 KiB
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"
|
|
|
|
namespace Carbon::Parse {
|
|
|
|
// Handles processing of a complete `adapt T` declaration.
|
|
auto HandleAdaptAfterIntroducer(Context& context) -> void {
|
|
auto state = context.PopState();
|
|
state.state = State::AdaptDecl;
|
|
context.PushState(state);
|
|
context.PushState(State::Expr);
|
|
}
|
|
|
|
// Handles processing of a complete `adapt T` declaration.
|
|
auto HandleAdaptDecl(Context& context) -> void {
|
|
// TODO: This is identical to HandleBaseDecl other than the `NodeKind`,
|
|
// and very similar to `HandleNamespaceFinish` and `HandleAliasFinish`.
|
|
// We should factor out this common work.
|
|
auto state = context.PopState();
|
|
|
|
context.AddNodeExpectingDeclSemi(state, NodeKind::AdaptDecl,
|
|
Lex::TokenKind::Adapt,
|
|
/*is_def_allowed=*/false);
|
|
}
|
|
|
|
} // namespace Carbon::Parse
|