handle_base.cpp 899 B

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 `base: B` declaration.
  7. auto HandleBaseDecl(Context& context) -> void {
  8. auto state = context.PopState();
  9. auto semi = context.ConsumeIf(Lex::TokenKind::Semi);
  10. if (!semi && !state.has_error) {
  11. context.EmitExpectedDeclSemi(context.tokens().GetKind(state.token));
  12. state.has_error = true;
  13. }
  14. if (state.has_error) {
  15. context.RecoverFromDeclError(state, NodeKind::BaseDecl,
  16. /*skip_past_likely_end=*/true);
  17. return;
  18. }
  19. context.AddNode(NodeKind::BaseDecl, *semi, state.subtree_start,
  20. state.has_error);
  21. }
  22. } // namespace Carbon::Parse