handle_adapt.cpp 1.1 KB

123456789101112131415161718192021222324252627282930
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. #include "toolchain/parse/context.h"
  5. #include "toolchain/parse/handle.h"
  6. namespace Carbon::Parse {
  7. // Handles processing of a complete `adapt T` declaration.
  8. auto HandleAdaptAfterIntroducer(Context& context) -> void {
  9. auto state = context.PopState();
  10. state.state = State::AdaptDecl;
  11. context.PushState(state);
  12. context.PushState(State::Expr);
  13. }
  14. // Handles processing of a complete `adapt T` declaration.
  15. auto HandleAdaptDecl(Context& context) -> void {
  16. // TODO: This is identical to HandleBaseDecl other than the `NodeKind`,
  17. // and very similar to `HandleNamespaceFinish` and `HandleAliasFinish`.
  18. // We should factor out this common work.
  19. auto state = context.PopState();
  20. context.AddNodeExpectingDeclSemi(state, NodeKind::AdaptDecl,
  21. Lex::TokenKind::Adapt,
  22. /*is_def_allowed=*/false);
  23. }
  24. } // namespace Carbon::Parse