handle_type.cpp 1.2 KB

1234567891011121314151617181920212223242526272829303132
  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 type declaration or definition after its introducer.
  8. static auto HandleTypeAfterIntroducer(Context& context,
  9. StateKind after_params_state_kind)
  10. -> void {
  11. auto state = context.PopState();
  12. context.PushState(state, after_params_state_kind);
  13. context.PushState(StateKind::DeclNameAndParams, state.token);
  14. }
  15. auto HandleTypeAfterIntroducerAsClass(Context& context) -> void {
  16. HandleTypeAfterIntroducer(context, StateKind::DeclOrDefinitionAsClass);
  17. }
  18. auto HandleTypeAfterIntroducerAsInterface(Context& context) -> void {
  19. HandleTypeAfterIntroducer(context, StateKind::DeclOrDefinitionAsInterface);
  20. }
  21. auto HandleTypeAfterIntroducerAsNamedConstraint(Context& context) -> void {
  22. HandleTypeAfterIntroducer(context,
  23. StateKind::DeclOrDefinitionAsNamedConstraint);
  24. }
  25. } // namespace Carbon::Parse