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