handle_pattern_list.cpp 1.7 KB

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