handle_pattern.cpp 926 B

12345678910111213141516171819202122232425262728
  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 HandlePattern(Context& context) -> void {
  8. auto state = context.PopState();
  9. switch (context.PositionKind()) {
  10. case Lex::TokenKind::OpenParen:
  11. context.PushStateForPattern(StateKind::PatternListAsTuple,
  12. state.in_var_pattern);
  13. break;
  14. case Lex::TokenKind::Var:
  15. context.PushStateForPattern(StateKind::VariablePattern,
  16. state.in_var_pattern);
  17. break;
  18. default:
  19. context.PushStateForPattern(StateKind::BindingPattern,
  20. state.in_var_pattern);
  21. break;
  22. }
  23. }
  24. } // namespace Carbon::Parse