handle_pattern.cpp 846 B

1234567891011121314151617181920212223242526
  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(State::PatternListAsTuple,
  12. state.in_var_pattern);
  13. break;
  14. case Lex::TokenKind::Var:
  15. context.PushStateForPattern(State::VariablePattern, state.in_var_pattern);
  16. break;
  17. default:
  18. context.PushStateForPattern(State::BindingPattern, state.in_var_pattern);
  19. break;
  20. }
  21. }
  22. } // namespace Carbon::Parse