handle_namespace.cpp 804 B

123456789101112131415161718192021222324
  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. auto HandleNamespace(Context& context) -> void {
  8. auto state = context.PopState();
  9. context.PushState(state, State::NamespaceFinish);
  10. context.PushState(State::DeclNameAndParams, state.token);
  11. }
  12. auto HandleNamespaceFinish(Context& context) -> void {
  13. auto state = context.PopState();
  14. context.AddNodeExpectingDeclSemi(state, NodeKind::Namespace,
  15. Lex::TokenKind::Namespace,
  16. /*is_def_allowed=*/false);
  17. }
  18. } // namespace Carbon::Parse