handle_pattern_list.cpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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/check/context.h"
  5. namespace Carbon::Check {
  6. auto HandleImplicitParamListStart(Context& context,
  7. Parse::ImplicitParamListStartId node_id)
  8. -> bool {
  9. context.node_stack().Push(node_id);
  10. context.param_and_arg_refs_stack().Push();
  11. return true;
  12. }
  13. auto HandleImplicitParamList(Context& context,
  14. Parse::ImplicitParamListId node_id) -> bool {
  15. auto refs_id = context.param_and_arg_refs_stack().EndAndPop(
  16. Parse::NodeKind::ImplicitParamListStart);
  17. context.node_stack()
  18. .PopAndDiscardSoloNodeId<Parse::NodeKind::ImplicitParamListStart>();
  19. context.node_stack().Push(node_id, refs_id);
  20. // The implicit parameter list's scope extends to the end of the following
  21. // parameter list.
  22. return true;
  23. }
  24. auto HandleTuplePatternStart(Context& context,
  25. Parse::TuplePatternStartId node_id) -> bool {
  26. context.node_stack().Push(node_id);
  27. context.param_and_arg_refs_stack().Push();
  28. return true;
  29. }
  30. auto HandlePatternListComma(Context& context,
  31. Parse::PatternListCommaId /*node_id*/) -> bool {
  32. context.param_and_arg_refs_stack().ApplyComma();
  33. return true;
  34. }
  35. auto HandleTuplePattern(Context& context, Parse::TuplePatternId node_id)
  36. -> bool {
  37. auto refs_id = context.param_and_arg_refs_stack().EndAndPop(
  38. Parse::NodeKind::TuplePatternStart);
  39. context.node_stack()
  40. .PopAndDiscardSoloNodeId<Parse::NodeKind::TuplePatternStart>();
  41. context.node_stack().Push(node_id, refs_id);
  42. return true;
  43. }
  44. } // namespace Carbon::Check