handle_adapt.cpp 1.0 KB

1234567891011121314151617181920212223242526272829
  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. namespace Carbon::Parse {
  6. // Handles processing of a complete `adapt T` declaration.
  7. auto HandleAdaptAfterIntroducer(Context& context) -> void {
  8. auto state = context.PopState();
  9. state.state = State::AdaptDecl;
  10. context.PushState(state);
  11. context.PushState(State::Expr);
  12. }
  13. // Handles processing of a complete `adapt T` declaration.
  14. auto HandleAdaptDecl(Context& context) -> void {
  15. // TODO: This is identical to HandleBaseDecl other than the `NodeKind`,
  16. // and very similar to `HandleNamespaceFinish` and `HandleAliasFinish`.
  17. // We should factor out this common work.
  18. auto state = context.PopState();
  19. context.AddNodeExpectingDeclSemi(state, NodeKind::AdaptDecl,
  20. Lex::TokenKind::Adapt,
  21. /*is_def_allowed=*/false);
  22. }
  23. } // namespace Carbon::Parse