handle_call_expr.cpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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 HandleCallExpr(Context& context) -> void {
  8. auto state = context.PopState();
  9. context.PushState(state, State::CallExprFinish);
  10. context.AddNode(NodeKind::CallExprStart, context.Consume(),
  11. state.subtree_start, state.has_error);
  12. if (!context.PositionIs(Lex::TokenKind::CloseParen)) {
  13. context.PushState(State::CallExprParamFinish);
  14. context.PushState(State::Expr);
  15. }
  16. }
  17. auto HandleCallExprParamFinish(Context& context) -> void {
  18. auto state = context.PopState();
  19. if (state.has_error) {
  20. context.ReturnErrorOnState();
  21. }
  22. if (context.ConsumeListToken(NodeKind::CallExprComma,
  23. Lex::TokenKind::CloseParen, state.has_error) ==
  24. Context::ListTokenKind::Comma) {
  25. context.PushState(State::CallExprParamFinish);
  26. context.PushState(State::Expr);
  27. }
  28. }
  29. auto HandleCallExprFinish(Context& context) -> void {
  30. auto state = context.PopState();
  31. context.AddNode(NodeKind::CallExpr, context.Consume(), state.subtree_start,
  32. state.has_error);
  33. }
  34. } // namespace Carbon::Parse