handle_pattern_list.cpp 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. #include "toolchain/check/handle.h"
  6. namespace Carbon::Check {
  7. auto HandleParseNode(Context& context, 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 HandleParseNode(Context& context, Parse::ImplicitParamListId node_id)
  14. -> bool {
  15. // Note the Start node remains on the stack, where the param list handler can
  16. // make use of it.
  17. auto refs_id = context.param_and_arg_refs_stack().EndAndPop(
  18. 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 HandleParseNode(Context& context, Parse::TuplePatternStartId node_id)
  25. -> bool {
  26. context.node_stack().Push(node_id);
  27. context.param_and_arg_refs_stack().Push();
  28. return true;
  29. }
  30. auto HandleParseNode(Context& context, Parse::PatternListCommaId /*node_id*/)
  31. -> bool {
  32. context.param_and_arg_refs_stack().ApplyComma();
  33. return true;
  34. }
  35. auto HandleParseNode(Context& context, Parse::TuplePatternId node_id) -> bool {
  36. // Note the Start node remains on the stack, where the param list handler can
  37. // make use of it.
  38. auto refs_id = context.param_and_arg_refs_stack().EndAndPop(
  39. Parse::NodeKind::TuplePatternStart);
  40. context.node_stack().Push(node_id, refs_id);
  41. return true;
  42. }
  43. } // namespace Carbon::Check